Error not logged with Application_Error

I have an Asp.Net 4.0 Web Forms that throws the following error at a specific time

"Server Error in Application / MySiteDev."

This error only occurs from time to time. And this error does not trigger the Application_Error event, which is processed in Global.asax .

Since Application_Error is not triggered, what are all the other possible places that will have a log of this error event? Anything other than watching events?

Any way to find out the exceptions handled by the ASP.Net framework?

Note: customErrors mode="Off" . Also runAllManagedModulesForAllRequests="true"

UPDATE

Link from How to handle application level errors

The error handler defined in the Global.asax file will catch errors that occur during processing of requests in the ASP.NET runtime. For example, it will catch an error if the user requests a .aspx file that is not found in your application. However, it does not detect an error if the user requests a nonexistent .htm file. For nonASP.NET errors, you can create a custom handler in IIS. A custom handler will also not be called for server-level errors.

You cannot directly display error information for queries from the Global.asax file; you must transfer control to another page, usually a web forms page. When transferring control to another page, use the transfer method. This saves the current context so that you can get error information from the GetLastError method.

After processing the error, you must clear it by calling the ClearError method of the Server object (class HttpServerUtility).

CODE

  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> 

UPDATED LINKS

+6
source share
2 answers

This is a load balanced environment with fields A and B.

The team that deployed the web application confirmed that the configuration file was not copied correctly in one of the fields.

I think the application did a great job when it fell into the box and did not fall into box B. I think, since the config is not there, it was impossible to call Application_Error .

Tell me if you have a different opinion.

Note. The problem does not occur when they are redeployed

+1
source

Examine the logs in the event viewer, which should be logged both at the server level and at the application level.

The application error handler probably does not handle the event because it occurs before the application starts successfully and the context is created. Thus, it looks like the application configuration or server configuration is no longer processing the request.

Or the application encounters a problem early enough in the request life cycle, which even hangs after launch until the server decides to kill the process (for example, perhaps as an exception to StackOverflow mentioned by @MikeSmithDev).

+3
source

All Articles