how to prevent to go to the previous page?

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
 
G

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

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
 
E

Eric

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

"Anon User" <> 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
 
J

Joern Schou-Rode

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")
 
G

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

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top