473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting the aspx page an error occured on in Application_OnError

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
Nov 18 '05 #1
3 2509
I used Page.Error event

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

"Sam-I-Am" <sa****@3hgroup.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2
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...rs.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

Nov 18 '05 #3
Thanks for the reply

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

Thanks,

S

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Jt*************@cpmsftngxa10.phx.gbl...
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...rs.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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
1
by: z. f. | last post by:
Hi, i have a asp.net vb.net web appliation. it is compiled to release build with debug information. i have module to analyze errors in application_onError to trap all errors in my code and...
4
by: Bill | last post by:
Despite our best efforts occasionally in an aspx file, something like <%=x%> where x is not defined sqeaks by and I get the ugly asp error message. I want to be able to identify this particular...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
4
by: Pat | last post by:
In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
0
by: John | last post by:
I am writing a custom httpmodule, I can catch BeginRequest, EndRequest event, But I can not catch Error event, I tried throwing an error from my Web Service, creating a security exception (by...
6
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.