Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 664
user8456 Avatar asked Dec 05 '08 16:12

user8456


People also ask

How do I catch exceptions in global ASAX?

You can handle default errors at the application level either by modifying your application's configuration or by adding an Application_Error handler in the Global. asax file of your application. You can handle default errors and HTTP errors by adding a customErrors section to the Web. config file.

What are the 3 approaches to handle exceptions in a web application?

try catch finally 2. Use error events to deal with exceptions within the scope of an object. Page_Error Global_Error Application_Error 3. Use custom error pages to display informational messages for unhandled exceptions within the scope of a Web application.

What is an exception how exceptions are handled in ASP.NET application?

Apart from the try catch exception handling technique, the ASP.NET Framework has error handling events where exceptions can be caught. When there is an unhandled error at the code level, meaning if the code does not have a structured try catch block to handle exceptions, then that can be handled at the page level.

When you catch an exception What method can you use to get the type of the exception?

Place any code statements that might raise or throw an exception in a try block, and place statements used to handle the exception or exceptions in one or more catch blocks below the try block. Each catch block includes the exception type and can contain additional statements needed to handle that exception type.


1 Answers

HttpContext con = HttpContext.Current;
con.Request.Url.ToString()
like image 161
jlew Avatar answered Oct 18 '22 09:10

jlew