Created
January 21, 2014 11:57
-
-
Save kjeske/8538737 to your computer and use it in GitHub Desktop.
How to handle custom errors handling in ASP MVC 4+ and IIS 7+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.web> | |
<customErrors | |
mode="RemoteOnly" | |
// ResponseRewrite would be a better way, but is uses Server.Transfer so we have to use | |
// ResponseRedirect which redirects whole page. To do this better you have to wrap 404 errors | |
// in Application_Error | |
redirectMode="ResponseRedirect" | |
defaultRedirect="Error"> | |
<error statusCode="404" redirect="~/errors/ups/404" /> | |
<error statusCode="500" redirect="~/errors/ups/500" /> | |
</customErrors> | |
</system.web> | |
<system.webServer> | |
<httpErrors errorMode="Custom"> | |
<remove statusCode="403" /> | |
<error statusCode="403" responseMode="ExecuteURL" path="/errors/ups/403" /> | |
<remove statusCode="404" /> | |
<error statusCode="404" responseMode="ExecuteURL" path="/errors/ups/404" /> | |
<remove statusCode="500" /> | |
<error statusCode="500" responseMode="ExecuteURL" path="/errors/ups/500" /> | |
</httpErrors> | |
</system.webServer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment