“处理您的请求时发生异常.另外,在执行自定义错误页面时发生了另一个异常. [英] "An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page..."
问题描述
我正试图将MVC网站发布为Azure webrole.
I'm trying to publish an MVC website as an Azure webrole.
在本地运行时,一切正常.
When I run it locally, everything works fine.
但是一旦我将其发布到Azure并进行了一些MVC操作,我就会收到此错误:
But once I publish it to Azure and surf to some MVC action, I get this 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());
}
}
这是我的web.config:
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>
这是Error.cshtml:
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?
推荐答案
首先,在web.config中设置customErrors ="Off",然后重新部署以获得更详细的错误消息,以帮助我们诊断问题.您也可以将RDP导入实例,然后从IIS本地浏览到该站点以查看错误.
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" />
不过,首先要进行猜测-您有一些未设置为Copy Local = true的引用(最可能是Azure SDK引用).因此,您的所有依赖项都没有得到部署.
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.
更新:VS2013现在提供的第二个选项是远程调试云服务或虚拟机.
UPDATE: A second option now available in VS2013 is Remote Debugging a Cloud Service or Virtual Machine.
这篇关于“处理您的请求时发生异常.另外,在执行自定义错误页面时发生了另一个异常.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!