G
Guest
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
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