how to prevent to go to the previous page?

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

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,

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
 
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" <[email protected]> schreef in bericht
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
 
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")
 
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
 
Back
Top