How do I make exceptions thrown during a partial-update (from an UpdatePanel) to be thrown in the server, not to the browser? (please get in, easy)

Last post 09-09-2008 11:16 PM by chetan.sarode. 3 replies.

Sort Posts:

  • How do I make exceptions thrown during a partial-update (from an UpdatePanel) to be thrown in the server, not to the browser? (please get in, easy)

    09-09-2008, 8:06 PM
    • Member
      175 point Member
    • Weitzhandler
    • Member since 10-27-2007, 6:25 PM
    • Jerusalem
    • Posts 135

    usually when an exception is thrown u get a page saying "Server Error in "/"" (something like that - the main exception message of ASP.NET).

    however, I use an updatepanel, and the exceptions which are thrown during the partial update, doesn't show that error page, instead the page is sent back to the browser and the exception is considered as a client-side error and is shown by the browser's status bar

    does anyone know how to make the exception thrown from the server?

    Ps. can exceptions in web be thrown as in win applications (a yellow line, like debugging steps)?

     

     

    Shimmy
  • Re: How do I make exceptions thrown during a partial-update (from an UpdatePanel) to be thrown in the server, not to the browser? (please get in, easy)

    09-09-2008, 8:56 PM

    Weitzhandler,

    If your web project is run in debug mode, from the IDE, you can just put a breakpoint in your code the same as in a winforms app.  To get a redirect to an error page, you need to set up a customError page in you web config, and then set the AllowCustomErrorsRedirect  property on your script manager to true.  Here's a good post about your other options for handling asp.net ajax exceptions:

     http://weblogs.asp.net/zeeshanhirani/archive/2008/05/24/handling-errors-in-asp-net-ajax.aspx

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: How do I make exceptions thrown during a partial-update (from an UpdatePanel) to be thrown in the server, not to the browser? (please get in, easy)

    09-09-2008, 9:20 PM
    • Member
      175 point Member
    • Weitzhandler
    • Member since 10-27-2007, 6:25 PM
    • Jerusalem
    • Posts 135

    can't I just get such a page:

     

    Server Error in '/' Application.

    Input string was not in a correct format.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.FormatException: Input string was not in a correct format.

    Source Error:

    Line 10: 	'lblItemsInCart
    Line 11: 	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Line 12: 		Response.Write(Int32.Parse("sdf"))
    Line 13: 
    Line 14: 

    Source File: E:\Projects\********    Line: 12

    Stack Trace:

    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7467367
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
       System.Int32.Parse(String s) +23
       **.Page_Load(Object sender, EventArgs e) in E:\Projects\************.aspx.vb:12
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       wc.BasePage.OnLoad(EventArgs e) in E:\Projects\*****************.vb:80
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
     
     
    ??????????????
    Shimmy
  • Re: How do I make exceptions thrown during a partial-update (from an UpdatePanel) to be thrown in the server, not to the browser? (please get in, easy)

    09-09-2008, 11:16 PM
    Answer

    When an error occurs during partial-page updates in UpdatePanel controls, the default behavior is that a browser message box is displayed with an error message.

    http://asp.net/ajax/documentation/live/tutorials/CustomizingErrorHandlingforUpdatePanel.aspx

    In server code you can customize error handling by setting the AsyncPostBackErrorMessage property and handling the AsyncPostBackError event of the ScriptManager control. In client code you can customize error handing by handling the endRequest event of the PageRequestManager class.

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
Page 1 of 1 (4 items)