Search code examples
asp.netbrowser-history

How do I remove a page from the browser history?


I have an have an ASP.Net page which contains a button. This Page contains a ServerSide Paypal button.

When pushed my server does various clever things on the back end and then rewrites the response as a form and some javascript which posts this form to paypal..

This all works great.

However, if the user then elects to click back, they will arrive at my generated self-posting form and that will forward them again to Paypal.

I thought if I could find a way to have my generated form page not exist in the history, then this will solve my problem. but I have no idea how to correct this.

How can I remove my page from the history or just have it never appear?

Update: Thanks to all... Those are some great answers. Upvoted all good ones but went with splattne on account of clever use of hidden field rather than cookies for basis of decision.


Solution

  • I'm not sure if that can be done. But here is an idea how you could prevent that resubmit of the form.

    You could insert a hidden input in your form which at the beginning would be empty. On submit you'll write a value in that field and make sure you check on every submit attempt if this field is empty.

    If it is not empty on submit you know that the form was previously sent and you could warn the user.