0

我无法让我的 Application_Error 方法在 global.asax 中触发。我在 Application_Error 函数的第一行放置了一个断点,但它永远不会在那里中断。相反,服务器返回通常的黄色格式堆栈跟踪页面并说“发生了未处理的异常......”所以我知道正在抛出异常。

有什么建议吗?我正在使用 VS2010、C# 4.0,并在 Dev Web 服务器中运行它(通过 F5)。

全球.asax

void Application_Error(object sender, EventArgs e)
{
        int i;
        i = 3;   <==BREAKPOINT SET HERE, NEVER HITS
}

网络配置

<customErrors mode="Off" />
...
<compilation debug="true" targetFramework="4.0">

我在 Application_Error 被跳过时看到的页面:

Server Error in '/' Application.
--------------------------------------------------------------------------------
Invalid column name 'JobTypeID'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'JobTypeID'.

Source Error: 
Line 95: 
Line 96:             MyEntities context = Util.CurrentMasterContext();
Line 97:             UserRec = context.User
Line 98:                 .Include("Person")
Line 99:                 .Include("AccountType")
4

1 回答 1

1

好的,我记得(意识到)我有一个自定义的 HttpModule。这个处理程序没有为错误事件实现事件处理程序,所以我添加了一个,瞧,这确实触发了。

但是现在我的问题已经改变了:如果你注册了一个自定义的 HttpModule,这是否会破坏 global.asax 级别的所有事件的触发,即使是那些你的 HttpModule 没有处理的事件?

这对任何人都有意义吗?

于 2011-02-20T03:57:15.697 回答