Ignore exception in Application_Error event but maintain state

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Ignore exception in Application_Error event but maintain state

    Hi,
    I would like to ignore a certain exceptions in
    Application_Error event in Global.asax.cs file and still
    have the page's state be maintained. If I simply issue:

    Server.ClearError()

    I end up with a blank page. If I issue:

    Server.ClearError();
    Response.Redirect(Request.UrlReferrer.ToString());

    I end up with the page that I want to be displayed but
    it's state (TextBox's have been cleared) is lost.

    Thanks for your help,
    Terry
    twahl Guest

  2. Similar Questions and Discussions

    1. #32101 [Com]: Exception in unknown on line 0 when throwing exception inside exception handler
      ID: 32101 Comment by: dhopkins at DonHopkins dot com Reported By: ceefour at gauldong dot net Status: No...
    2. ASP.NET 2 Treeview does not maintain state
      I am new to ASP.NET so please bear with me.... I have a treeview in which the nodes are populated from a database. When I click on a node, some...
    3. Application_error & web services
      Hi all, I am practically tearing my hair out here!! In my global.asax file, I have in the Application_error() sub a call to a sub in a library...
    4. maintain the state of a hidden html control.
      Hi, I have a usercontrol which handles the menu functions which is included in the main form.My requirement is to pass a variable to the server...
    5. Application_Error event and 404 error?
      I implemet in Application_Error event in Global.asax, So now when some error occurs in application it send me email, the problem is that it consider...
  3. #2

    Default Re: Ignore exception in Application_Error event but maintain state

    what you need to do is catch the error before it bubbles up to the
    application level then you won't have all these problems.

    "twahl" <terry_wahl@msn.com> wrote in message
    news:007201c33c0e$aa1d4700$a601280a@phx.gbl...
    > Hi,
    > I would like to ignore a certain exceptions in
    > Application_Error event in Global.asax.cs file and still
    > have the page's state be maintained. If I simply issue:
    >
    > Server.ClearError()
    >
    > I end up with a blank page. If I issue:
    >
    > Server.ClearError();
    > Response.Redirect(Request.UrlReferrer.ToString());
    >
    > I end up with the page that I want to be displayed but
    > it's state (TextBox's have been cleared) is lost.
    >
    > Thanks for your help,
    > Terry

    Alvin Bruney Guest

  4. #3

    Default RE: Ignore exception in Application_Error event but maintain state

    Hi Terry,

    Based on my experience, we are not able to keep page's state after calling
    Server.ClearError(). To work around this problem, I suggest you to use
    structured exception (with try/catch/finally blocks) within your ASP .NET
    application.

    In addition, I recommend you the following articles on handling exception
    in ASP .NET:

    An Exception to the Rule, Part 1
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/ht[/url]
    ml/asp07232001.asp

    An Exception to the Rule, Part 2
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/ht[/url]
    ml/asp08232001.asp

    Hope this helps.

    Regards,
    HuangTM
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tian Min Huang Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139