Friday, March 1, 2013

How to override IIS error pages with the custom pages in MVC

First we should turn off custom error pages in <system.web> section:


<system.web>
    <customErrors mode="Off" />
</system.web>

And then enable it <system.webServer> section:

<system.webServer>
    <!-- Custom Error Pages -->
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <error statusCode="404" path="/Error/404" responseMode="ExecuteURL" />
      <error statusCode="500" path="/Error" responseMode="ExecuteURL" />
    </httpErrors>
</system.webServer>

No comments:

Post a Comment