Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Handling errors thrown in Application_Error()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Johnson - 06 Mar 2008 17:02 GMT
I have a web app that handles errors in the Gloabal.ascx's Application_Error().

It does some logging etc in there and if it throws an error, I want the app
to display a static html splash page rather than a yellow screen asp.net
error.

I have tried setting the custom error page and also a try catch in the
application_error with a server.transfer in the catch but it always seems to
go to a yellow screen asp.net error page (without any details if I set
customErrors to On, but it doesn't go to the page I have set as the custom
error page)

Any ideas how I can get it to show that page if it throws an error in
Application_Error?

Signature

Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com

George Ter-Saakov - 06 Mar 2008 18:00 GMT
Do you call HttpContext.ClearError  at the end of processing?

Second thing I would look at if the Application_Error throws exception as
well....

So theoretically your code should be something like this

protected void Application_Error(Object sender, EventArgs e)
{
   try
   {
       .....blablabla
   }
   finally
   {
       Context.ClearError();
       Response.Redirect("myerrorpage.htm");  //Or transfer.
   }
   catch(Exception e)
   {
       // do not know what to do. we stuck with exceptions.
   }
}

George.

>I have a web app that handles errors in the Gloabal.ascx's
>Application_Error().
[quoted text clipped - 13 lines]
> Any ideas how I can get it to show that page if it throws an error in
> Application_Error?
Phil Johnson - 07 Mar 2008 11:19 GMT
Hi George,

Thanks for the response, your suggestion would work, and when I changed to
use it it did help me resolve my underlying issue and switch back to the
declarative web.config approach....

It turned out my error page was only available to logged on users, which was
why the customErrors page was never being displayed.

The order now is that when an error occurs it goes into application_error in
global.asax.  If an error occurrs in the handling, the page detailed in the
customErrors in the web.config is displayed, which is what I initally hoped
would happen.

Signature

Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com

> Do you call HttpContext.ClearError  at the end of processing?
>
[quoted text clipped - 39 lines]
> > Any ideas how I can get it to show that page if it throws an error in
> > Application_Error?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.