customErrors和httpErrors的区别

ASP.NET-MVC 2427次浏览 本站
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>
 

发表评论

电子邮件地址不会被公开。 必填项已用*标注