文章分类

相关文章

customErrors和httpErrors的区别

分类:ASP.NET-MVC     发布:2016-10-23     来源:本站     浏览:1234 次
The customErrors attribute is used when the .net code is throwing an exception (404, 403, 500 etc) and 
the httpErrors attribute is used when IIS itself is throwing an exception.
So for example I have a simple mvc web application, I define the following config:
<system.web>
    <customErrors mode="On" defaultRedirect="Error.html">
        <error statusCode="403" redirect="/Error403" />
        <error statusCode="404" redirect="/Error404" />
        <error statusCode="500" redirect="/Error500" />
    </customErrors>
</system.web>
<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" >
    <remove statusCode="403"/>
    <remove statusCode="404"/>
    <remove statusCode="500"/>
    <!--path不能使用~/开头,直接/-->
    <error statusCode="403" responseMode="ExecuteURL" path="/Error403" />
    <error statusCode="404" responseMode="ExecuteURL" path="/Error404" />
    <error statusCode="500" responseMode="ExecuteURL" path="/Error500" />
  </httpErrors>
</system.webServer>

来源: <http://stackoverflow.com/questions/2480006/what-is-the-difference-between-customerrors-and-httperrors>
 

上一篇:好好经营你的30-40岁

下一篇:你该学会与孤独相处,更好地了解自己