Solved

page_error will not fire during a callback

Posted on 2009-07-08
1
638 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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