Application_Error 未触发

发布于 2024-10-18 08:57:01 字数 1261 浏览 0 评论 0原文

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

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

当 Application_Error 被跳过时我看到的Global.asax

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

web.config

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

页面:

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")

I'm not able to get my Application_Error method to fire in global.asax. I've placed a breakpoint in the first line of my Application_Error function but it never breaks there. Instead, the server is returning the usual yellow formatted stack trace page and saying that "An unhandled exception occurred...." so I know an exception is being thrown.

Any advice? I'm using VS2010, C# 4.0, and running this in the Dev web server (via F5).

Global.asax

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

web.config

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

Page that I see when Application_Error gets skipped:

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")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑轻吟梦一曲 2024-10-25 08:57:01

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

但现在我的问题发生了变化:如果您注册一个自定义 HttpModule,这是否会导致在 global.asax 级别触发所有事件,甚至是您的 HttpModule 未处理的那些事件?

这对任何人来说都有意义吗?

Ok, I remembered (realized) that I had a custom HttpModule. This handler was not implementing an event handler for the Error event so I added one and voila, this did fire.

But now my question has changed: if you register a custom HttpModule does this defeat the firing of all events at the global.asax level, even those events that your HttpModule isn't handling?

Does that make sense to any one?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文