473,387 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ASP.NET looping in the Application_Error handler

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

Nov 18 '05 #1
0 963

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Scott | last post by:
Hi there, I have an odd situation. I have exception handling set up in my Application_Error event handler in my global.asax. On my development box, errors get caught by the event handler fine...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
2
by: A.M | last post by:
Hi, I have the following code in Global.asax. Using a breakpoint, i can see that that all errors are being trapped in Application_Error and the event handler is being run properly. The problem...
0
by: Michael | last post by:
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...
2
by: Carl Johansen | last post by:
I've been reading the O'Reilly "ASP.NET Cookbook" 1st edition (Kittel and LeBlond), and it makes a recommendation about exception handling that seems a bit strange. They say that, if you want to...
6
by: Rippo | last post by:
I have a problem with the application_error event being fired from my asp.net application with windows 2003 server standard edition. The event fires fine from my test machine (XP) and all works...
1
by: David Herbst | last post by:
VS 2005 / .NET 2.0 Windows 2000 Server sp4 (on development as well as testing server) Using Web Deployment Project to build assemblies for testing and production servers. I added a Global.asax...
10
by: Nemisis | last post by:
Hi everyone, I am trying to create a custom error page, that the user gets shown when a error has occurred within my website. The code works perfectly, apart from when an invalid URL is typed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.