I have a general exception handler, Application_error in my global.asax where I’m trying to isolate all the uncaught exceptions on all my many pages. I don’t want to use Page_error to catch exception because it’s inefficient to call that on so many pages. So where in the exception can I find what page actually caused the exception?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
HttpContext con = HttpContext.Current; con.Request.Url.ToString()
Method 2
Remember, the page is not (should not) always be the cause of the exception. It could just as easily be coming from another assembly – and if you don’t have your logic in your codebehinds, it likely will be coming from another assembly. Don’t get me wrong, it is great to know which page, from the aspect of saying X Page caused Y exception in Z assembly.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0