How to get which page threw an exception to Application_error in aspx

坚强是说给别人听的谎言 提交于 2019-11-27 03:49:05

问题


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?


回答1:


HttpContext con = HttpContext.Current;
con.Request.Url.ToString()



回答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.



来源:https://stackoverflow.com/questions/344440/how-to-get-which-page-threw-an-exception-to-application-error-in-aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!