IIS7不会显示ASP.Net错误消息或堆栈跟踪

tlo*_*lin 5 asp.net debugging iis-7

我正在尝试调试ASP.Net 3.5应用程序中的错误.我们最近将应用程序从IIS6移到了7.在IIS6中,代码如下:

Throw new Exception("My message")
Run Code Online (Sandbox Code Playgroud)

将显示一个页面,提供错误消息,附近的代码行和堆栈跟踪(使用"debug"编译模式,没有自定义错误).

在IIS7中,"详细"错误消息仅提供模块和错误代码:

HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.

Detailed Error Information
Module  global.asax
Notification    BeginRequest
Handler StaticFile
Error Code  0x00000000
Requested URL   [My URL]
Physical Path   [My Path]
Logon Method    Not yet determined
Logon User  Not yet determined
Failed Request Tracing Log Directory    [My Directory]
Run Code Online (Sandbox Code Playgroud)

我甚至设置了失败请求跟踪,它声称提供堆栈跟踪,但仍然没有给我任何行号或错误消息,只有模块名称和HTTP状态.

No. 111.
Severity    Warning 
Event   -MODULE_SET_RESPONSE_ERROR_STATUS 
  ModuleName    global.asax 
  Notification  1 
  HttpStatus    500 
  HttpReason    Internal Server Error 
  HttpSubStatus 0 
  ErrorCode 0 
  ConfigExceptionInfo
  Notification  BEGIN_REQUEST
  ErrorCode The operation completed successfully. (0x0)
Run Code Online (Sandbox Code Playgroud)

如何获取IIS6中的信息?我已经知道错误在global.asax中,我需要一个行号和一个特定的错误消息.

此外,我不确定这是否相关,但该网站是预编译的,并且aspnet_compiler.exe显然在编译时将web.config"debug"开关设置为false(即使使用"-d"选项).我的machine.config没有"部署"标记.我只是将"debug"设置回true并在编译后回收,我认为这会使网站恢复到调试模式,对吧?

小智 2

错误页面配置中有一个设置,告诉 IIS 显示本地和远程请求的详细信息级别。您可能想验证其配置是否正确。要访问此设置,请启动 Internet 信息服务管理器并转至

Site Home\Error Pages\Edit Feature Settings
Run Code Online (Sandbox Code Playgroud)

确保在生产中禁用此设置