Getting the aspx page an error occured on in Application_OnError

S

Sam-I-Am

Hi

I am using the Application_OnError event to handle exceptions in a web app.
How can I get a reference to the page the exception occurred on from within
the Application_OnError event?

Thanks,

S
 
K

Konrad Rotuski

I used Page.Error event

Dim ex As Exception = Server.GetLastError()
'.....
and Server.ClearError() after i got all information i needed about error
 
S

Steven Cheng[MSFT]

Hi Sam,

Generally we can use the HttpContext.Current.Handler to retrieve current
request's processing handler, for example:

System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler ;

but, don't think it'll be helpful in the Application_Error event since at
that time the current processing is throwed to application level and won't
return to page level. I agree with Konrad that we can use the Page_Error
even
if we want to do some page level operations when the unhandled error
occur.
Here is a tech article discussing on the error handling in ASP.NET

#Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/en-us/dnaspp/html/customerrors.asp?frame=t
rue

Hope also helps. Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Sam-I-Am

Thanks for the reply

I have simply used:
string page = Context.Request.Url.ToString();

Thanks,

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top