Anti-Refresh repeat commit, anti-back method

Source: Internet
Author: User
Keywords Submit nbsp; buttons forms
Tags anti- asp button buttons click client close customer

Web page anti-refresh repeat submission, anti-rewind solution

Disable the Submit button after submission (most people do)

What if the customer submits and presses F5 refresh?

Use session

Before the submitted page is the database processing:

After the data is processed, modify session ("OK") =false.

Data processing success immediately redirect to another page

After the operation is really a problem, you can use the Jump page, close this page, if there are parameters according to the conditions to control, it should be good to do, you can directly modify the value of window.location, the parameters are all changed, so that is almost.

Disadvantage: Simply using Response.Redirect will no longer be effective, because the user from one page to another page, we must use the client code to clear the Location.history. Note that this method clears the last access history, not all the access records. Click the Back button, and then click the Back button, you can see that this is the page before the page opened! (Of course, this is under the condition that your client has JavaScript enabled.) )

What if the customer presses back?

Prevent page back--Disable caching

When we do the database add operation, if we allow back, and happened to have refreshed the page, will be added again, no doubt this is not what we need, like the general online many prohibit caching code, sometimes unreliable, then you just in the operation of the page plus on it, in the page to specify the new page to be directed, Back again, see if it will not be back to the operation of the page, has actually been deleted this history

ASP:
Response.Buffer = True
Response.ExpiresAbsolute = Now ()-1
Response.Expires = 0
Response.CacheControl = "No-cache"

ASP. NET:
Response.buffer=true;
Response.expiresabsolute=datetime.now.addseconds (-1);
response.expires=0;
Response.cachecontrol= "No-cache";

How can I disable the browser's Back button? or "How to prevent users from clicking the Back button to return to a previously viewed page?" ”

Unfortunately, we cannot disable the browser's Back button.

Prevent web pages from receding-new windows

Pop-up form page with window.open, click to close the page after submission, processing the submitted ASP page is also used to eject, set the target of the form, point submission window.open ("xxx.asp", "_blank"), and then use JS to submit the form, After completion window.close ();
Simply put, it is the time to submit the form to pop up a new window and close this window. How do I get back to the open window for window.open ()? Where can we go back?

Oh, wordy a pile of nonsense, know how to deal with it? Mix client and server-side scripts.

If session ("OK") =true then
Response.Write "Error, submitting"
Response.End
End If

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.