Solved

page_error will not fire during a callback

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Iteration Help (Asp.net VB) 5 35
Error running webpage local computer 7 26
ASP Repeater control - onl;y show if flag is true 7 22
How to repeat the data 4 30
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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