Solved

page_error will not fire during a callback

Posted on 2009-07-08
1
626 Views
Last Modified: 2012-05-07
Hi, I'm working with visual studio 2005, visual basic .net and I'm trying to use the Page_Error method to catch unhandled exceptions in my code.  I want to catch errors during callbacks, is there something about the way callbacks are handled that prevents the Page_Error method from being called because no matter what I do I don't seem to be able to get it to fire.

The sequence of events is:

Javascript makes call to RaiseCallbackEvent
RaiseCallbackEvent calls a function with an error in it (Throw New ArgumentNullException("error"))
At this point I expect Page_Error to be raised, but the code immediately calls GetCallbackResult.

I have autoeventwireup = "false" in my page but I'm using Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error.  I thought that using Handles means you don't need autoeventwireup set to true.

I've tried:
Adding the Addhandler to the Page_Load Event on my page.
Setting autoeventwireup = "true"
Changing the Handles Me.Error to MyBase.Error (I read somewhere that that would fix it)

All to no avail.  I appreciate anyone who can shed some light on this subject for me.

Edit: I've done some more testing and found that the Page_Error works just as I would expect if I'm NOT in a callback.  If I place the fake error in the page load event the Page_Error event does fire.  This makes me believe that everything is wired up correctly, I suppose I'm just not using the correct method for catching errors during a callback.  

Thanks
0
Comment
Question by:Schweeneh
1 Comment
 

Accepted Solution

by:
Schweeneh earned 0 total points
ID: 24814641
I did a little more research and I eventually stumbled across the solution.  The answer is in the GetCallbackEventReference function.

GetCallbackEventReference(Me, "arg", "doNothing", "", "raiseError", True)

When registering the javascript to do the callback on the page I hadn't even noticed that one of the overloads of this function includes a client side error handling function.  I'm not sure how it works but during a callback errors are routed to this function instead of the original callback function (doNothing in the case above).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now