Ignore exception in Application_Error event but maintain state

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
 
A

Alvin Bruney

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.
 
T

Tian Min Huang

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top