Application_Error not firing

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Apr 21, 2009 at 4:21 PM
Hi, 

I am using the February 2008 WCSF version with VS2008.  I am using the Application_Error in the global.asax for error logging.
 It is working fine in my localhost and on our staging server, however when we copied as is the website from staging to production, the application error seems not to be fired.

The application is compiled in debug mode and i have commented out the following statement in the web.config for my localhost, stating and production
<add name="ExceptionLoggerHttpModule" type="Microsoft.Practices.CompositeWeb.EnterpriseLibrary.ExceptionLogger, Microsoft.Practices.CompositeWeb.EnterpriseLibrary"/>

I have been reasearching it for a couples of days and still do not know what is the cause of this issue. Please help..

Thanks
Apr 24, 2009 at 7:41 PM

Hi,

 

There should be no special consideration in a WCSF application regarding the Application_Error in the global.asax. It should work as is any other ASP.net application.

 

What is your Application_Error handler doing?

One things that comes to my mind, specially if you are doing custom error logging, is: what happens if the code inside the Application_Error handler throws an exception? In such case nobody would handle it, and you will be redirected to the default error page, as if the handler wouldn't exists (The exception is not even logged in the event viewer).
To check if this is your case you might start Application_Error  method with a call to Server.ClearError(), this is most probably not going to throw an exception and will let you know that Application_Error was fired (you will see a blank page instead of the original exception). For example

 

protected void Application_Error(object sender, EventArgs e)

{

    Server.ClearError();

    

    .....

}

 

 

Hope it helps!

 

Matias Bonaventura

http://blogs.southworks.net/matiasb