how to prevent to go to the previous page?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    how to prevent to go to the previous page?

    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


  • Alexey Smirnov

    #2
    Re: how to prevent to go to the previous page?

    On Nov 9, 11:26 am, "Eric" <e...@sdsclem.p owrote:
    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="JavaS cript">
    if(history.leng th>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

    Comment

    • Eric

      #3
      Re: how to prevent to go to the previous page?

      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" <alexey.smirnov @gmail.comschre ef in bericht
      news:66aaee6b-3923-4d24-9927-4a2e589df487@35 g2000pry.google groups.com...
      On Nov 9, 11:26 am, "Eric" <e...@sdsclem.p owrote:
      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="JavaS cript">
      if(history.leng th>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


      Comment

      • Joern Schou-Rode

        #4
        Re: how to prevent to go to the previous page?

        On Sun, 09 Nov 2008 13:30:46 +0100, Eric <erl@sdsclem.po 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 (HttpCacheabili ty.NoCache)

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

        if (Request.Sessio n["foo"] != null) Response.Redire ct("bar.aspx")

        --
        Joern Schou-Rode

        Comment

        • Mark Rae [MVP]

          #5
          Re: how to prevent to go to the previous page?

          "Eric" <erl@sdsclem.po wrote in message
          news:%23bQm7bmQ JHA.1160@TK2MSF TNGP02.phx.gbl. ..
          >>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?
          >>
          ><script language="JavaS cript">
          >if(history.len gth>0)
          >history.go(+1) ;
          ></script>
          >>
          >If user disabled javascript that wouldn't work and you would need to
          >look for another approach.
          >
          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.
          This is a very common question - there are hundreds of articles about it on
          the web:


          There really is no 100% guaranteed method for this which will work in all
          cases on all browsers on all platforms. Principally, this is because the
          navigation buttons are part of the browser, not the web application...


          --
          Mark Rae
          ASP.NET MVP


          Comment

          • Alexey Smirnov

            #6
            Re: how to prevent to go to the previous page?

            On Nov 9, 1:30 pm, "Eric" <e...@sdsclem.p owrote:
            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

            Comment

            Working...