Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

We have some logic for displaying custom error pages in our ASP.NET application through overriding Page.OnError. Now, when an error occurs within that error handling routine I can redirect somewhere else using the in web.config.

This works for most errors. Yet, I cannot find how to display a custom error page (or anything at all!) when getting e.g. a StackOverflowException. Obviously I cannot do any more processing insode ASP in such a case as practically anything will result in some allocation on the stack. The same is probably true for OutOfMemory, though I have not found any sensible way to test this. Is there any possibility I could still display something (possibly static) to the user, e.g. directly from IIS instead from ASP?

share|improve this question
If you're catching the exception sufficiently far out of the code that fails, there's no reason why you shouldn't be able to run cleanup code - the problematic stuff will already be out of scope. – sq33G 11 hours ago
Well, basically the question is: How do I handle an unforseen exception inside the error handler? I can do that using customErrors in web.config, but not for OOM and SO. – user2606634 10 hours ago
Can you catch the error in Global.asax? – sq33G 10 hours ago
The error handling is currently situated in an override of OnError in our root page template. Since not even the customErrors approach works in the case of a SO I doubt that I will be able to do any processing in Global.asax. That's why I was asking for an approach using IIS in the original post. – user2606634 10 hours ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.