how to prevent to go to the previous page?

Discussion in 'ASP .Net' started by Eric, Nov 9, 2008.

  1. Eric

    Eric Guest

    Hi,

    the user gets a form to fill. All the filled values are put into session
    variables.
    I want to prevent that he could click to the previous arrow of the browser
    and then comes back to the form. Is that possible with asp.net?

    Or, is it possible to clear the session when leaving the form page by
    clicking the previous arrow?

    Thanks
    Eric
     
    Eric, Nov 9, 2008
    #1
    1. Advertising

  2. On Nov 9, 11:26 am, "Eric" <> wrote:
    > Hi,
    >
    > the user gets a form to fill. All the filled values are put into session
    > variables.
    > I want to prevent that he could click to the previous arrow of the browser
    > and then comes back to the form. Is that possible with asp.net?
    >
    > Or, is it possible to clear the session when leaving the form page by
    > clicking the previous arrow?
    >
    > Thanks
    > Eric


    Hi Eric

    this could do the trick

    <script language="JavaScript">
    if(history.length>0)
    history.go(+1);
    </script>

    If user disabled javascript that wouldn't work and you would need to
    look for another approach.

    Hope this helps
     
    Alexey Smirnov, Nov 9, 2008
    #2
    1. Advertising

  3. Eric

    Eric Guest

    Thanks a lot.
    If you don't mind, could you tell me more (or refer) about the another
    approach?
    This is a good solution, but if possible, i would prefer a more waterproof
    way.
    Thanks

    "Alexey Smirnov" <> schreef in bericht
    news:...
    On Nov 9, 11:26 am, "Eric" <> wrote:
    > Hi,
    >
    > the user gets a form to fill. All the filled values are put into session
    > variables.
    > I want to prevent that he could click to the previous arrow of the browser
    > and then comes back to the form. Is that possible with asp.net?
    >
    > Or, is it possible to clear the session when leaving the form page by
    > clicking the previous arrow?
    >
    > Thanks
    > Eric


    Hi Eric

    this could do the trick

    <script language="JavaScript">
    if(history.length>0)
    history.go(+1);
    </script>

    If user disabled javascript that wouldn't work and you would need to
    look for another approach.

    Hope this helps
     
    Eric, Nov 9, 2008
    #3
  4. On Sun, 09 Nov 2008 13:30:46 +0100, Eric <> wrote:

    > This is a good solution, but if possible, i would prefer a more
    > waterproof way.


    Make sure that the input form does not get cached client-side:

    Response.Cache.SetCacheability(HttpCacheability.NoCache)

    Reject/redirect the user from the input form if the session variable is
    already set:

    if (Request.Session["foo"] != null) Response.Redirect("bar.aspx")

    --
    Joern Schou-Rode
    http://malamute.dk/
     
    Joern Schou-Rode, Nov 9, 2008
    #4
  5. On Nov 9, 1:30 pm, "Eric" <> wrote:
    > Thanks a lot.
    > If you don't mind, could you tell me more (or refer) about the another
    > approach?
    > This is a good solution, but if possible, i would prefer a more waterproof
    > way.
    > Thanks


    Another appoach is what Joern told you. You used a session for storing
    the values, so you can check if session already has the values or not.
    If session has stored values you would redirect to the next page.
    There is another limit - session will not work if user has cookies
    disabled. So, theoretically speaking, this is not a 100% solution. In
    the same time you use session to store values and if session will not
    work your form will not work as well. And if cookies are required to
    use your site (it seems) then this maybe the best way to prevent
    people from going back
     
    Alexey Smirnov, Nov 9, 2008
    #5
    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. Greg Krzeszkowski
    Replies:
    3
    Views:
    614
    Peter Blum
    Mar 3, 2005
  2. ABC
    Replies:
    2
    Views:
    468
    John Timney \( MVP \)
    Jan 14, 2006
  3. ABC
    Replies:
    2
    Views:
    443
    libero familymac news
    Jan 14, 2006
  4. bill
    Replies:
    6
    Views:
    9,237
  5. Replies:
    3
    Views:
    109
Loading...

Share This Page