Webforms Refresh problem

后端 未结 2 1533
清酒与你
清酒与你 2020-12-22 07:27

This is probably a simple question for every WebForms developer but I am knew to this scene. I have a page that has an \"ADD\" button on it that results in a jquery popup w

2条回答
  •  礼貌的吻别
    2020-12-22 08:11

    that's a common problem. Here's explanation and solution of the problem.

    When a web form is submitted to a server through an HTTP POST request, a web user that attempts to refresh the server response in certain user agents can cause the contents of the original HTTP POST request to be resubmitted, possibly causing undesired results, such as a duplicate web purchase. To avoid this problem, many web developers use the PRG(Post/Redirect/Get) pattern.

    copied from wiki (LINK)

    simplest solution can be Response.Redirect to the same page (i.e. if you page is named default.aspx write Response.Redirect("default.aspx")). if you do this browser refresh button will just load the page as if you have typed in address bar URL and navigated to it.

    here's SO question How to stop unwanted postback that might be useful as well.

提交回复
热议问题