我的 MVC3 应用程序显示 403、404 和 500 状态代码的自定义错误页面,但浏览到 trace.axd 会显示以下 YSOD:
Server Error in '/' Application.
Trace Error
Description: Trace.axd is not enabled in the configuration file for this application. Note: Trace is never enabled when <deployment retail=true />
Details: To enable trace.axd, please create a <trace> tag within the configuration file located in the root directory of the current web application. This <trace> tag should then have its "enabled" attribute set to "true".
<configuration>
<system.web>
<trace enabled="true"/>
</system.web>
</configuration>
所以我禁用了跟踪,这很好,但是为什么没有显示 500 页面,因为这是从服务器返回的 403?我对 404、403 或 500 真的很满意——只要它不是丑陋的黄色屏幕!
编辑:在本地主机上运行时,我得到了 500 和 YSOD,但它实际上是服务器上的 403,更接近我的预期 - 但仍然没有自定义错误页面。服务器上的标准错误页面也略有不同:
Server Error in '/' Application.
Trace Error
Description: The current trace settings prevent trace.axd from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable trace.axd to be viewable on remote machines, please create a <trace> tag within the configuration file located in the root directory of the current web application. This <trace> tag should then have its "localOnly" attribute set to "false".
<configuration>
<system.web>
<trace localOnly="false"/>
</system.web>
</configuration>