Application_OnError handler not working

G

Guest

Hi,

I have a web application which has an error handling layer which is
performing quite well.

Any exceptions caught in a try/catch block are fed to this layer and they
pass the exception to an error page which gives up some useful information.

The problem is, if an error occurs outside of the try/catch we have code in
the Global.asax's Application_OnError handler which does the exact same thing
(get the last error, gather the required info, clear the error, clear State,
tell the (non-.NET) framework to redirect to the error page, etc.) Trouble
is, this doesn't seem to be happening.

I replicated an Object ref not found exception in a try/catch and all was
well. I tried a DivideByZero exception outside of the try/catch and I got
the basic 'yellow page'.

Does anyone know a reason why this code wouldn't execute? I have no page
level error handling for unexpected exceptions, so it should propogate to the
Application level and be caught in the Global.asax.

I tried debugging the application but it didn't step into the Global.asax,
just gave the 'yellow page'.

Any ideas would be much appreciated.
 
A

Alvin Bruney [MVP]

Yup, it should trap the error at the global handler. Try this - I suspect
the global file may be corrupted - handle the appdomain unhandled exception
event from the global asax code behind or the thread unhandled exception. If
you can't catch those, I would copy the contents of the code behind/besides
file, delete and add a new global asax file and paste in the contents of the
code behind/besides file.
 
G

Guest

Thanks, Alvin,

I was looking into the AppDomain.Current.UnhandledException event a few days
ago but wasn't sure where to implement it (each page or in the Global.asax).

It turns out that my Global.asax was in the wrong folder (my app has over a
hundred projects, each with their own Global, but there wasn't a copy in the
root directory). I placed one there and everything works as desired now.

Thanks again,

Mac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top