处理刷新表单提交后 [英] Handling Refreshes After Form Submission

查看:163
本文介绍了处理刷新表单提交后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是不允许的表单重新提交一个刷新的最佳方式? !的IsPostBack 不处理刷新。我一直在使用一个布尔变量设置为true首次提交试过,但似乎我每次加载页面时被重置。

What is the best way to disallow a form to resubmit on a refresh? !IsPostBack doesn't handle refreshes. I have tried using a bool variable that sets to true on initial submission, but it seems to be resetting every time I load the page.

我读过一些关于Cookie,但我不知道如何设置这些高达页面之间传递。

I've read a bit about cookies but I'm not sure how to setup these up to pass between pages.

我的设置是:


  • Default.aspx的(安培; Default.aspx.cs)

  • Results.aspx(安培; Results.aspx.cs)

我是否设置cookies在像SessionState会的web.config?是否有更好的东西比cookie使用?

Do I setup cookies in web.config like SessionState? Is there something better to use than cookies?

推荐答案

,因为我觉得你可以看看邮政/重定向/模式的 PRG模式
维基百科

as i think you could look at Post/redirect/Pattern PRG pattern from wikipedia

HTTP 1.1规范引入了HTTP响应303 code到
  确保在这种情况下,网络用户的浏览器可以安全地
  刷新服务器响应,而不会导致最初的HTTP POST
  请求重新提交。

The HTTP 1.1 specification introduced the HTTP 303 response code to ensure that in this situation, the web user's browser can safely refresh the server response without causing the initial HTTP POST request to be resubmitted.

它只是在于成功后重定向后,因此,在一个幂等用户刷新查询结果做,而不是POST。它具有额外的优势浏览器忘记有关POST在其历史上,这意味着后退按钮不会提交任何

It simply consists in redirecting after a successful post, so that the user refresh results in an idempotent GET to be done rather than a POST. It has the additional advantage that the browser "forgets" about the POST in its history, which means the back button won't submit either.

甚至你可以用你的数据库提交的数据,该数据是否已经存在或不是基于某些主键或唯一标识符前检查。

even you can check before submitting the data with your database, whether the data already exists or not based on some Primary key or unique identifier.

但你检查这PRG模式,它可能会帮助你。

but you do check this PRG pattern, it may helps you .

响应重定向。在asp.net

这篇关于处理刷新表单提交后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆