ASP.NET Looping in Application_Error handler

From: Michael (Michael_at_discussions.microsoft.com)
Date: 06/16/04


Date: Wed, 16 Jun 2004 07:25:23 -0700

Hi,

I have an ASP.NET application that catches un-handled exceptions in the Application_Error method and writes the details to the Event Log. But, if I do a Server.ClearError() followed by either a Server.Transfer or Response.Redirect to another ASP.NET page, then it causes .NET to re-enter the Application_Error function.

I thought that maybe there is an exception being thrown in the Application_Error function, but after placing a try/catch block around it I found that there was not.

So, I removed the Server.ClearError and added a defaultRedirect to my web.config file instead. This stopped the above effects from happening, but it complained about the settings:

mode="On" defaultRedirect="unhandledexception.aspx"

After trying various paths to the page I changed it to redirect to a HTML file. And it worked!!! So, I then changed it to an ASP page with a Response.Redirect to the ASP.NET page and I got the page I wanted.

These events have raised a few questions I am hoping someone could answer:

1) Why did a call to Server.Transfer and Response.Redirect in the Application_Error function cause ASP.NET to continue re-entering Application_Error?

2) Why did ASP.NET not like my customErrors element in the web.config when I had a defaultRedirect to a ASP.NET page?

3) Should I keep an eye for any side-effects of going out to a ASP page and then back into an ASP.NET page in respect to the way I handle errors using the web.config?

Any thoughts on these issues would be appreciated because they have been driving me NUTS and I can't work out why it is happening.

Many Thanks

Michael



Relevant Pages

  • ASP.NET looping in the Application_Error handler
    ... I thought that maybe there is an exception being thrown in the Application_Error function, but after placing a try/catch block around it I found that there was not. ... I removed the Server.ClearError and added a defaultRedirect to my web.config file instead. ... After trying various paths to the page I changed it to redirect to a HTML file. ... Should I keep an eye for any side-effects of going out to a ASP page and then back into an ASP.NET page in respect to the way I handle errors using the web.config? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: get_aspx_ver.aspx ???
    ... If the defaultRedirect attribute is set to an HTML file or to ... an ASP file, the request for the Get_aspx_ver.aspx file does not return the ...
    (microsoft.public.dotnet.framework.aspnet)
  • saving current asp to server
    ... to the server side in html file format. ... I got a very nice reply back from Scott McNair. ... Sub Write ... I have a pre-developed ASP that contains all the ...
    (microsoft.public.inetserver.asp.general)
  • Re: How to replace string in a HTML file ??
    ... > I have an .ASP html file in a server. ... > and I know the name to match in the orginal HTML file. ... > These are string I want to change for playing directly from network ... If you don't know regular expression syntax, take some time to read perlre, ...
    (comp.lang.perl.misc)
  • re: complicated include?
    ... Write an ASP page that reads a given HTML file into a ... if intBodEnd> 0 then ... This approach has the added advantage that you ASP pages, ... Microsoft FrontPage MVP ...
    (microsoft.public.frontpage.client)

Loading