Hello, I use the Application_Error method to trap all errors in my application. However, on one of my post-backs, this method is not being called when an error occurs, resulting in an "Exception Not Handled By User Code" error, and hence an ugly error page
rather than the one my Application_Error calls. My Application_Error method also performs additional error logging. It almost seems like the postback in question is bypassing the Global.asax file altogether. Could this be possible? What reasons, or under what
conditions would Application_Error not be called? This problem is very frustrating to me. I don't want to have to add a bunch of try-catch blocks around EVERY block of code in my application just to catch and handle errors nicely, as that is what I thought
the global.asax function was supposed to do. Any help would be appreciated. Thanks! Michael
usualy exceptions don't get caught, if they occour in different thread.
one of the solutions is to write HttpModule, witch would handle unhandled exceptions.
but you don't need to use try - catch everywhere, best practice is to use them only in situations, where you have no control over validating data or smth, so
good example would be to use try catch when you write to a file/send over internet or smth,
bad example would be to use try catch to check if division is possible
try {
divide
} catch (divide by zero exception) {
}
better is to check if you're not dividing by zero, than to wait for exception.
Giedrius
---------------------
If system doesn't work, change it
>>> usualy exceptions don't get caught, if they occour in different thread. I'm not actively starting a new thread. Is it possible the .NET framework is starting it instead for me? My error handling has been working well for months now. I'm just suprised that
all of a sudden, the global application_error method isn't working. As far as I know, the code isn't even getting there (based on logging statements I put there). I'm not ruling out user error here either - I just need to figure out what has changed about
this page that causes the event not to fire. I may try a Page_Error() handler as well to see if that catches this problem. Michael
well, i believe lots of ppl have encountered this trouble before. u just perfrom a search thru google and you will find a lot of them. Personally, i strongly recommend u to read this article:
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites
and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any
software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Marked as answer by Bo Chen – MSFT on May 11, 2007 07:29 AM
mjacobsca
Member
27 Points
22 Posts
Application_Error Not Being Called
May 08, 2007 09:36 PM|LINK
dziedrius
Member
42 Points
15 Posts
Re: Application_Error Not Being Called
May 09, 2007 09:36 AM|LINK
usualy exceptions don't get caught, if they occour in different thread.
one of the solutions is to write HttpModule, witch would handle unhandled exceptions.
but you don't need to use try - catch everywhere, best practice is to use them only in situations, where you have no control over validating data or smth, so
good example would be to use try catch when you write to a file/send over internet or smth,
bad example would be to use try catch to check if division is possible
try {
divide
} catch (divide by zero exception) {
}
better is to check if you're not dividing by zero, than to wait for exception.
---------------------
If system doesn't work, change it
mjacobsca
Member
27 Points
22 Posts
Re: Application_Error Not Being Called
May 09, 2007 03:48 PM|LINK
Bo Chen – MS...
All-Star
17706 Points
1389 Posts
Re: Application_Error Not Being Called
May 10, 2007 08:30 AM|LINK
Hi mjacobsca,
well, i believe lots of ppl have encountered this trouble before. u just perfrom a search thru google and you will find a lot of them. Personally, i strongly recommend u to read this article:
http://www.developer.com/net/asp/print.php/961301
also, this one maybe is helpful too : http://www.15seconds.com/issue/030102.htm
Hope my suggestion helps :)
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.