我正在使用MVC 3.我编辑了我的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>
现在当我遇到运行时错误时,我仍然看到:
Server Error in '/' Application.
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.
完成链接到我的源代码:-(
请注意,当我运行时,我将其设置为“Release”,然后使用CTRL F5
运行答案 0 :(得分:0)
你在本地运行吗?您会注意到只有远程用户才会被发送到您的自定义错误页面。
mode="RemoteOnly"
要在本地查看此功能,您可以将值设置为On
:
mode="On"
所以你是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="On" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
</system.web>
</configuration>