[英]httperrors in system.webserver not working on azure
I would like to catch all errors into a default.aspx file, no matter what happens on the server. 无论服务器上发生什么情况,我都希望将所有错误捕获到default.aspx文件中。
In the web.config, I added: 在web.config中,我添加了:
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" defaultPath="~/Default.aspx" existingResponse="Replace" >
<remove statusCode="404"/>
<remove statusCode="500"/>
<error statusCode="404" path="~/Default.aspx" responseMode="ExecuteURL"/>
<error statusCode="500" path="~/Default.aspx" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
It does not work. 这是行不通的。 In an question, I read about allow overriding of the HttpErrors section, but adding something in the configSection does not work, since the type element is missing.
在一个问题中,我阅读了有关HttpErrors部分的允许覆盖的内容,但是由于缺少type元素,因此无法在configSection中添加某些内容。 No idea what is required there.
不知道那里需要什么。
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=ZZZZZZZZZ" requirePermission="false" />
<section name="httpErrors" allowOverride="true"/>
</configSections>
If you would like to handle 404 error messages in ASP.NEt Website, then all you need is to have following section in Web.Config - 如果您想在ASP.NEt网站中处理404错误消息,则只需在Web.Config中包含以下部分-
<customErrors mode="On" defaultRedirect="DefaultRedirectErrorPage">
<error statusCode="404" redirect="Home/About"/>
</customErrors>
For detailed understanding of different ways of error handling in ASP.Net - Ref this MSDN Resource 有关ASP.Net中错误处理的不同方式的详细了解-请参考此MSDN资源
If you wanted to do that at httpErrors level, then try this - 如果您想在httpErrors级别上执行此操作,请尝试以下操作-
<httpErrors errorMode="Custom" existingResponse="Replace">
<!--Remove inherited 500 error page setting -->
<remove statusCode='404' subStatusCode='-1'/>
<!--Override the inherited 500 error page setting with the 'My500.html' as its path-->
<error statusCode='404' subStatusCode='-1' prefixLanguageFilePath='' path='/home/index' responseMode='ExecuteURL'/>
</httpErrors>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.