c# - C# 中的重新提交限制

标签 c#

重新提交后如何限制之前的操作。例如,如果我单击一个按钮,如果我重新提交(f5)该页面将刷新,那么我们之前单击的按钮将再次执行。所以我不想再执行一次。那么你能帮我解决这个问题吗?

最佳答案

您应该阅读有关PRG 模式的内容:

Post/Redirect/Get (PRG) is a web development design pattern that prevents some duplicate form submissions, creating a more intuitive interface for user agents (users). PRG implements bookmarks and the refresh button in a predictable way that does not create duplicate form submissions.

更多关于此here .

其工作方式的简短说明:

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 pattern1 — instead of returning a web page directly, the POST operation returns a redirection command.

关于c# - C# 中的重新提交限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21431550/

相关文章:

c# - 变量如何存储在类中及其执行流程?

c# - 尝试在 WPF 中绘制矩形立方体的边缘但未成功

c# - 在查询中使用当前登录的用户

C# WinForms 标签将显示,但不显示文本

c# - 如果小数部分为零,如何删除小数点分隔符?

c# - 带连字符的 html 属性与 asp.net mvc

c# - 查看元素是否包含子元素的最快方法是什么?

c# - 哈希表与字典

javascript - 数据库未更新错误 - Entity Framework

c# - 带有数据源和组合框的数据 GridView