c# – Application_Error未记录错误
我有一个Asp.Net 4.0 Web窗体应用程序,在某些时候会抛出以下错误
此错误有时会出现.并且此错误未触发在Global.asax中处理的Application_Error事件. 由于这不是触发Application_Error,所有其他可能的地方将有这个错误事件的日志?除了事件查看器以外还有什么吗? 有没有办法找出ASP.Net框架处理的异常? 注意:customErrors mode =“Off”.另外runAllManagedModulesForAllRequests =“true” UPDATE 参考文献How to: Handle Application-Level Errors
码 protected void Application_Error(object sender,EventArgs e) { //Get the exception object Exception exception = Server.GetLastError().GetBaseException(); //Get the location of the exception string location = Request.Url.ToString(); if (!String.IsNullOrEmpty(location)) { string[] partsOfLocation = location.Split('/'); if (partsOfLocation != null) { if (partsOfLocation.Length > 0) { location = partsOfLocation[partsOfLocation.Length - 1]; } } //Maximum allowed length for location is 255 if (location.Length > 255) { location = location.Substring(0,254); } } string connectionString = ConfigurationManager.ConnectionStrings[UIConstants.PayrollSQLConnection].ConnectionString; ExceptionBL exceptionBL = new ExceptionBL(connectionString); exceptionBL.SubmitException(exception.Message,location); Log.Logger.Error(exception.Message); } CONFIG <system.web> <compilation debug="true" targetFramework="4.0" /> <pages validateRequest="false"></pages> <httpRuntime requestValidationMode="2.0" /> <customErrors mode="Off"/> <authentication mode="Windows"></authentication> <identity impersonate="true" userName="domainxxxx" password="xxxx"/> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <httpErrors errorMode="Detailed" /> </system.webServer> 更新的参考文献 > Application_Error not firing 解决方法
检查事件查看器中的日志,该日志应记录服务器级别和应用程序级别的错误.
应用程序错误处理程序可能不处理事件,因为它是在应用程序成功启动并创建上下文之前发生的.因此,似乎应用程序配置或服务器配置停止处理请求. 或者,应用程序在请求生命周期中尽早遇到问题,即使在启动之后,它也会“挂起”,直到服务器决定终止进程(例如,可能以@MikeSmithDev提到的StackOverflowException的形式). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |