How do I stop the Back and Refresh buttons from resubmitting my form?

后端 未结 13 1250
时光说笑
时光说笑 2020-11-27 15:16

I am doing web development.

I have a page to do with credit card, which when user click \"refresh\" or \"Back\", the transaction will be performed one more time, wh

13条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 15:43

    Place this code on the form page

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    
    Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
    
    Response.Cache.SetLastModified(DateTime.Now);
    
    Response.Cache.SetAllowResponseInBrowserHistory(false);
    

提交回复
热议问题