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

Discussion in 'ASP .Net' started by phancey, Feb 21, 2008.

  1. phancey

    phancey Guest

    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
    phancey, Feb 21, 2008
    #1
    1. Advertising

  2. phancey

    Aidy Guest

    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.

    "phancey" <> wrote in message
    news:...
    > 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
    >
    Aidy, Feb 21, 2008
    #2
    1. Advertising

  3. phancey

    phancey Guest

    Re: ASP.NET Error redirect then use Back button (or programmedbutton)

    On Feb 21, 5:16 pm, "Aidy" <> wrote:
    > 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.
    >
    > "phancey" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > hi,

    >
    > > I've got anasp.netapp. In case of unhandled exceptions, the
    > > web.config is set up toredirectthe user to anerrorpage. 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 anerrorthen i cannot
    > > rely on the dataset (as this could be the cause of theerror), 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 theerroron the page but this was a backup for unhandled
    > > exceptions.

    >
    > > Any help appreciated.
    > > Phil- Hide quoted text -

    >
    > - 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
    phancey, Feb 22, 2008
    #3
  4. phancey

    Aidy Guest

    > 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.
    Aidy, Feb 23, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHk=?=

    How are MSDN Newsgroups programmed?

    =?Utf-8?B?U2FuZHk=?=, Feb 13, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    321
    Patrick Olurotimi Ige
    Feb 14, 2005
  2. Pandora Xero

    Free Games Programmed in C++?

    Pandora Xero, Aug 6, 2003, in forum: C++
    Replies:
    4
    Views:
    1,373
    David T. Croft
    Aug 11, 2003
  3. Santi
    Replies:
    10
    Views:
    713
    Duane Hebert
    Jul 15, 2004
  4. ogalve
    Replies:
    3
    Views:
    334
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Feb 7, 2007
  5. Replies:
    0
    Views:
    262
Loading...

Share This Page