Can Application_EndRequest be used instead of Application_Error?
I want to handle all uncaught exceptions in my ASP.NET application. I want to show the UI to the user, but NOT redirect it (so the url will be the original url that threw the exception). I also have ELMAH which is configured by the end user (well, of course the administrator really is, but not me). Elmah attaches a handler to the event Application.Error
and registers it there.
Now I have two possible places to handle the error and generate the output Application_Error
and Application_EndRequest
. The logical place would be Application_Error
, but this has two problems:
- If I don't remove the exception with
ClearError()
, ASP.NET will replace my output with its own default output. - But if I remove it with
ClearError()
, then ELMAH might not get an exception because the order of execution of the event handler is undefined.
I have verified that the error is still persisting in Application_EndRequest
, so I can do it there, but it looks somehow ... wrong. Can I get in trouble by doing this?
source to share
No one has answered this question yet
See similar questions:
or similar: