18

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?

Lars A. Brekken
  • 20,385
  • 3
  • 23
  • 27
user8456
  • 338
  • 1
  • 4
  • 12

2 Answers2

32
HttpContext con = HttpContext.Current;
con.Request.Url.ToString()
jlew
  • 10,052
  • 1
  • 30
  • 55
3

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.

Joseph Ferris
  • 12,244
  • 3
  • 43
  • 72