ASP.NET / Web.config中:只的customErrors重定向404重定向、Web、NET、ASP

2023-09-03 16:27:02 作者:去暴漫里捡节操°

我有这样的情况:

一个用户来到我的网站和followes一个链接,至极犯规存在了,他应该被重定向到一个自定义的errorPage。 (即作品)

A user comes to my site and followes a link, wich doesnt exists anymore, he should be redirected to a custom errorpage. (that works)

如果用户做一些事情,这将引发一个错误,他应该看到的堆栈跟踪和真正的errorPage。

If a user does something, that throws an error, he should see the Stacktrace and the real Errorpage.

这是我目前的Web.config文件:

This is my current Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.web>
        <customErrors>
          <error statusCode="404" redirect="/errors/404.htm" />
        </customErrors>
        <compilation debug="true" strict="false" explicit="true" />
    </system.web>
</configuration>

通过这样的结构,一个404将被重定向到正确的网站,但一个HTTP 500将显示为如下:

with this configuration, a 404 will be redirected to the right site, but a HTTP 500 will be shown as following:

在/应用服务器错误

说明:服务器上出现应用程序错误。此应用程序prevent当前自定义错误设置的应用程序错误的远程查看(出于安全原因)的细节。它可以,但是,可以通过在本地服务器计算机上运行的浏览器查看。

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

详细信息:要启用此特定错误消息的详细信息可查看远程计算机上,请在网络[.config文件在位于当前Web应用程序根目录下的配置文件中创建一个标记。然后应将此标记的mode属性设置为关。

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web [.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".

[...]

但在这种情况下,我想说明的堆栈跟踪。

But in this case i want to show the stacktrace.

我怎样才能做到这一点?

How can i do this?

注意::我们是在Linux上与单&LT; - 的FastCGI - > Lighttpd的建筑

Note: We're on Linux with a Mono <- FastCGI -> Lighttpd construction.

推荐答案

雷凡Halens的答案是正确的,但是这不是实际的问题。

Ray Van Halens Answer is correct, but this was not the actual problem.

之所以没有表现出异常堆栈是单声道本身就是一个错误。有没有其他的办法,然后写一个自己的错误页面,堆栈跟踪被dispayed。

The reason for not showing stacktrace is a bug in mono itself. There is no other way then write an own error page where the stacktrace is dispayed.