在过去的两周里,我遇到了一个我无法弄清楚的情况,也许你们已经通过了相同的问题或耳朵/了解它并能帮助我。什么能导致Application_Error不被调用?
我有我的机器和其他机器上运行良好的ASP.NET项目,每次我试图锤炼查询字符串我得到的是被投掷由System.Exception的
问题是一个错误的时间,在这个特定的机器中(巫婆在荷兰),Application_Error永远不会捕获异常,它会将异常消息保存到日志中(因为在我的应用程序中应该这样做),但它不会“中断”Web应用程序......它只是继续!
如何以及如何使这成为可能?
为例着想,这是我的网页(HttpCache canot调用这个样子,但我使用的Web.HttpCache对象仅仅是点)
if(Request.QueryString["user"] != HttpCache["MYAPP-user"]) {
myApp.DebugWrite("User was tempered.");
throw System.Exception("User was tempered.");
}
和在Global.asax的我
...
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
if (Server.GetLastError() != null)
{
Exception objErr = Server.GetLastError().GetBaseException();
String url = Request.Url.ToString();
String msg = objErr.Message;
String trc = objErr.StackTrace.ToString();
Response.Clear();
StringBuilder html = new StringBuilder();
// fill up html with html code in order to present a nice message
Response.Write(html.ToString());
Server.ClearError();
Response.Flush();
Response.End();
}
}
...
在我的测试机器上,我总是得到带有错误信息的html,以及日志中的消息...在这台特定的机器上,我只看到日志中的错误,但应用程序继续 !!!
的web.config是完全一样在所有的机器和此Web应用程序的.NET 2.0
运行时,它可能是什么?
-1不知道你是否notest,但异常从来没有得到的到的Application_Error – balexandre 2009-10-02 11:49:00
你应该只是做了评论而不是-1。 :( – azamsharp 2009-10-02 18:14:55