Cos*_*aut 5 c# trace custom-error-pages axd asp.net-mvc-3
我的 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>
Run Code Online (Sandbox Code Playgroud)
所以我禁用了跟踪,这很好,但是为什么没有显示 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>
Run Code Online (Sandbox Code Playgroud)
由于没有回复,我在 Twitter 上询问了 @shanselman,他建议<deployment retail = "true" />可以解决这个问题,但它仍然返回相同的 YSOD。
最后我通过删除 paths.IgnoreRoute("{resource}.axd/{*pathInfo}"); 解决了这个问题 来自路由配置。看起来不太正确,但它确实有效。
| 归档时间: |
|
| 查看次数: |
2113 次 |
| 最近记录: |