“Server Error in ‘/MySiteDev’ Application” .
此错误有时会出现.并且此错误未触发在Global.asax中处理的Application_Error事件.
由于这不是触发Application_Error,所有其他可能的地方将有这个错误事件的日志?除了事件查看器以外还有什么吗?
有没有办法找出ASP.Net框架处理的异常?
注意:customErrors mode =“Off”.另外runAllManagedModulesForAllRequests =“true”
UPDATE
参考文献How to: Handle Application-Level Errors
An error handler that is defined in the Global.asax file will only catch errors that occur during processing of requests by the ASP.NET runtime. For example,it will catch the error if a user requests an .aspx file that does not occur in your application. However,it does not catch the error if a user requests a nonexistent .htm file. For non-ASP.NET errors,you can create a custom handler in Internet Information Services (IIS). The custom handler will also not be called for server-level errors.
You cannot directly output error information for requests from the Global.asax file; you must transfer control to another page,typically a Web Forms page. When transferring control to another page,use Transfer method. This preserves the current context so that you can get error information from the GetLastError method.
After handling an error,you must clear it by calling the ClearError method of the Server object (HttpServerUtility class).
码
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="domain\xxxx" password="xxxx"/> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <httpErrors errorMode="Detailed" /> </system.webServer>
更新的参考文献
> Application_Error not firing
> Global.asax event Application_Error is not firing
> Application_Error does not fire?
> How to: Handle Application-Level Errors