Ignore exception in Application_Error event but maintain state

  • Thread starter Thread starter twahl
  • Start date Start date
T

twahl

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
 
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.
 
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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/ht
ml/asp07232001.asp

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

Hope this helps.

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