我无法让我的 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")