MVC Error redirect doesn't seem to redirect for me in MVC3
I am using MVC 3. I have edited my Web.Release.Config
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
</system.web>
</configuration>
Now when I get a run time error I am still seeing:
Server Error in '/' Appl开发者_C百科ication.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Complete with a link to my SOURCE CODE :-(
Note that when I run I have it set to "Release" and I run with CTRL F5
Are you running this locally? You'll notice that only remote users will be sent to your custom error page.
mode="RemoteOnly"
To see this working locally too you can set the value to On
:
mode="On"
So you're Web.Release.Config will look like:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<customErrors defaultRedirect="GenericError.htm"
mode="On" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
</system.web>
</configuration>
精彩评论