PC Review


Reply
Thread Tools Rate Thread

Application_OnError handler not working

 
 
=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
Guest
Posts: n/a
 
      10th Oct 2007
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.
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      11th Oct 2007
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.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$24.99


"cashdeskmac" <(E-Mail Removed)> wrote in message
news:E4ECF2FE-95EB-413D-A558-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
Guest
Posts: n/a
 
      11th Oct 2007
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

"Alvin Bruney [MVP]" wrote:

> 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.
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless Author Plug
> OWC Black Book 2nd Edition
> Exclusively on www.lulu.com/owc
> $24.99
>
>
> "cashdeskmac" <(E-Mail Removed)> wrote in message
> news:E4ECF2FE-95EB-413D-A558-(E-Mail Removed)...
> > 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.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application_OnError Global Server.GetLastError = No Info Richard Coltrane Microsoft ASP .NET 2 10th Jan 2007 02:41 AM
Application_OnError loop with custom object =?Utf-8?B?TWFydHkgVS4=?= Microsoft ASP .NET 1 23rd Sep 2004 06:47 PM
Application_OnError in IIS 6 Problem! Steve Taylor Microsoft ASP .NET 4 15th Sep 2004 07:42 PM
Getting the aspx page an error occured on in Application_OnError Sam-I-Am Microsoft ASP .NET 3 10th Jun 2004 12:36 AM
HELP!!! Exception handler only working from VS IDE Tim Greenwood Microsoft C# .NET 4 15th Oct 2003 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 PM.