I'm trying to publish an MVC website as an Azure webrole.
我正在尝试发布一个MVC网站作为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:
但是一旦我将它发布到Azure上,并浏览到一些MVC操作,我就会得到这个错误:
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:
这是我的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:
这是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?
什么会导致这个异常,为什么我不能在本地复制它?
4 个解决方案
#1
172
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.
首先,在web中设置customErrors = "Off"。配置和重新部署以获得更详细的错误消息,这将帮助我们诊断问题。您还可以在实例中使用RDP,并从IIS本地浏览站点以查看错误。
<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.
不过,第一个猜测是——您有一些引用(很可能是Azure SDK引用)没有设置为Copy Local = true。所以,您所有的依赖项都没有被部署。
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.
更新:VS2013中的第二个选项是远程调试云服务或虚拟机。
#2
3
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.
我没有使用Azure,但是我在本地得到了相同的错误。使用
#3
0
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.
我只有在redirectMode="ResponseRewrite" (redirectMode="ResponseRedirect"工作得很好)的情况下才有这个问题,以上的解决方案都不能帮助我解决这个问题。但是,一旦我将服务器的应用程序池的“托管管道模式”从“经典”改为“集成”,自定义错误页面就会像预期的那样出现。
#4
0
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>
#1
172
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.
首先,在web中设置customErrors = "Off"。配置和重新部署以获得更详细的错误消息,这将帮助我们诊断问题。您还可以在实例中使用RDP,并从IIS本地浏览站点以查看错误。
<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.
不过,第一个猜测是——您有一些引用(很可能是Azure SDK引用)没有设置为Copy Local = true。所以,您所有的依赖项都没有被部署。
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.
更新:VS2013中的第二个选项是远程调试云服务或虚拟机。
#2
3
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.
我没有使用Azure,但是我在本地得到了相同的错误。使用
#3
0
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.
我只有在redirectMode="ResponseRewrite" (redirectMode="ResponseRedirect"工作得很好)的情况下才有这个问题,以上的解决方案都不能帮助我解决这个问题。但是,一旦我将服务器的应用程序池的“托管管道模式”从“经典”改为“集成”,自定义错误页面就会像预期的那样出现。
#4
0
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>