Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expire ASP.Net page

Tags:

c#

asp.net

How can I set an ASP.Net web page to expire so that if the user clicks the submit button, he/she will get a page expired error if the browser's back button is pushed to try to go back and press submit again?

like image 225
Russ Clark Avatar asked Feb 24 '10 20:02

Russ Clark


2 Answers

Use HttpResponse.Cache to control the cacheability of the page. This gives you control over options such the expiration of the page from the cache and the Cache-Control HTTP headers.

like image 186
pmarflee Avatar answered Sep 30 '22 09:09

pmarflee


First off, use the Post-Redirect-Get pattern when the user submits the form. This will prevent them from being able to use the back button easily. To do this, all you really need to do is issue a Response.Redirect() call after you finish processing the form, even if it's to the same URL.

Secondly, you could consider using a unique id field in the form that is tied to the submission process, so that if the submission is completed, the same id cannot be used again. The suitability of this would depend on what you're doing though.

like image 43
womp Avatar answered Sep 30 '22 09:09

womp