如何在MVC3中获取trace.axd的自定义错误页面?

我的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  Details: To enable trace.axd, please create a  tag within the configuration file located in the root directory of the current web application. This  tag should then have its "enabled" attribute set to "true".      

所以我有跟踪禁用,这很好,但为什么500页面没有显示,因为这是从服务器返回的403? 我真的很满意404,403或500 – 只要它不是一个丑陋的黄色屏幕!

编辑:当我在localhost上运行时,我和YSOD一起获得了500,但它实际上是服务器上的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  tag within the configuration file located in the root directory of the current web application. This  tag should then have its "localOnly" attribute set to "false".      

由于没有回复,我在Twitter上询问@shanselman,谁建议可以解决它,但它仍然返回相同的YSOD。

最后我通过删除routes.IgnoreRoute(“{resource} .axd / {* pathInfo}”)来解决它。 来自路由配置。 看起来不太对劲,但它确实有效。

按照@Cosmologinaut的建议删除IgnoreRoute并不适合我,因为他说错了。 我找到了一个更好的解决方案,即删除Web.config文件中的跟踪HTTP处理程序:

         

导航到/trace.axd现在为我们提供了404 Not Found而不是500 Internal Server Error。