"An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page..."
Solution 1
First, set customErrors = "Off" in the web.config and redeploy to get a more detailed error message that will help us diagnose the problem. You could also RDP into the instance and browse to the site from IIS locally to view the errors.
<system.web>
<customErrors mode="Off" />
First guess though - you have some references (most likely Azure SDK references) that are not set to Copy Local = true. So, all your dependencies are not getting deployed.
Get to the detailed error first and update your question.
UPDATE: A second option now available in VS2013 is Remote Debugging a Cloud Service or Virtual Machine.
Solution 2
I wasn't using Azure, but I got the same error locally. Using <customErrors mode="Off" />
seemed to have no effect, but checking the Application logs in Event Viewer revealed a warning from ASP.NET which contained all the detail I needed to resolve the issue.
Solution 3
If you add this to your web.config transformation file, you can also set certain publish options to have debugging enabled or disabled:
<system.web>
<customErrors mode="Off" defaultRedirect="~/Error.aspx" xdt:Transform="Replace"/>
</system.web>
Solution 4
When publishing to IIS, by Web Deploy, I just checked the File Publish Options and executed. Now it works! After this deploy the checkboxes do not need to be checked. I don't think this can be a solutions for everybody, but it is the only thing I needed to do to solve my problem. Good luck.
Solution 5
I had this problem with only with redirectMode="ResponseRewrite"
(redirectMode="ResponseRedirect"
worked fine) and none of the above solutions helped my resolve the issue. However, once I changed the server's application pool's "Managed Pipeline Mode" from "Classic" to "Integrated" the custom error page appeared as expected.
Related videos on Youtube
Ilya Kogan
Updated on February 04, 2021Comments
-
Ilya Kogan over 3 years
I'm trying to publish an MVC website as an Azure webrole.
When I run it locally, everything works fine.
But once I publish it to Azure and surf to some MVC action, I get this error:
Server Error in '/' Application.
Runtime Error
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
I don't understand how the error handler can encounter an exception, because errors are handled in the default way:
public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } }
This is my web.config:
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web.webPages.razor> <appSettings> <add key="webpages:Enabled" value="false" /> </appSettings> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers> <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <controls> <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> </configuration>
This is Error.cshtml:
@model System.Web.Mvc.HandleErrorInfo @{ ViewBag.Title = "Error"; } <h2> Sorry, an error occurred while processing your request. </h2>
What can cause this exception, and why can't I reproduce it locally?
-
Jack almost 11 yearsMan, your errors throw errors. That some serious ish :)
-
Jakub Konecki almost 11 yearsI suggest you enable detailed error logging in Management Portal and review the logs on FTP site.
-
drch almost 11 yearsIs there anything in your layout that may be the culprit?
-
Ilya Kogan almost 11 years@drch No, nothing has changed in the layout since it last worked.
-
-
Ilya Kogan almost 11 yearsSetting customErrors to "off" finally showed some real exceptions. I'm investigating them now.
-
drzaus over 9 yearsSince it's resulting in an IIS error, you can customize them too as a fallback a la benfoster.io/blog/aspnet-mvc-custom-error-pages
-
GuiPab almost 8 yearsMy customErrors are "Off", but i continue to see the "Sorry, an error occurred while processing your request." error. Could you help me here? @Ilya Kogan
-
Paul Zahra over 7 years+1 simply because setting customerror = off allowed me to see that the error was caused because I had used a website solution as a template for another website and had forgotten to clear out the bin folder, i.e. it was a duplication issue.
-
Aamol about 5 yearsHow Oracle come into this picture?