ASP.NET Error redirect then use Back button (or programmed button)

  • Thread starter Thread starter phancey
  • Start date Start date
P

phancey

hi,

I've got an asp.net app. In case of unhandled exceptions, the
web.config is set up to redirect the user to an error page. If the
user then clicks the back button to retry, they have lost all the data
they entered. This could be quite a lot of data. Is there a way to
handle this? I tried SavePageStateToPersistenceMedium but the
LoadPageState is not fired when going back so this doesn't work. And
the back button only works if I set Cacheability to NoCache.

If the page is redirected by me (which it is on a successful post)
then I store the info in a dataset Session variable and provide the
user with a Back button that restores the page using the Session
variable. But if the redirection is because of an error then i cannot
rely on the dataset (as this could be the cause of the error), but how
do I stop the user losing the data.

I could remove tha automatic redirection from the config file and put
in a global page_error handler that issued a javascript alert or just
showed the error on the page but this was a backup for unhandled
exceptions.

Any help appreciated.
Phil
 
Surely those settings are only for unhandled exceptions? If there is a
chance your code will throw an exception, just put it in a try/catch block
and handle the error as appropriate.
 
Surely those settings are only for unhandled exceptions?  If there is a
chance your code will throw an exception, just put it in a try/catch block
and handle theerroras appropriate.










- Show quoted text -

Yes it is for an unhandled exception. That's the point though. Unless
it was one that I was expecting I wanted to take them off to a
standard error page that told them to contact the Helpdesk if it
happened again. Sure, I can put try catches around everything but then
there wouldn't be any unhandled exceptions so the setting would be
pointless. On the assumption that the setting is useful and that there
are therefore some unhandled exceptions, how can I prevent them from
losing all their entry after they have been redirected to the error
page?

thanks
Phil
 
how can I prevent them from
losing all their entry after they have been redirected to the error
page?

I don't think there is a way. Like I said, if you think your code might
throw an exception then handle it properly. I'm assuming the exception is
things like duplicate data violating database integrity, or null values in
fields etc. If so you should code around those issues rather than just
letting the error handle page pick them up.
 
Back
Top