Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page..."

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?

like image 879
Ilya Kogan Avatar asked Jun 24 '13 11:06

Ilya Kogan


People also ask

What causes Server Error in '/' Application?

The “Server error in '/' application” can occur if there is a typo in the file extension, for example a file or URL that references test. htl instead of test. html. If the file name is correct, then you may need to add the MIME typeto the server.

What does an exception occurred while processing your request mean?

An exception occurred while processing this request (Status:0) This error may occur if the browser has an outdated copy of the page in its cache. The following applies to Internet Explorer, for other browsers please check online or ask your local IT helpdesk.


2 Answers

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.

like image 173
viperguynaz Avatar answered Nov 03 '22 08:11

viperguynaz


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.

like image 25
SharpC Avatar answered Nov 03 '22 09:11

SharpC