asp.net问题与回发后F5,因为它做什么,它应该 [英] asp.net issue with F5 after postback, because it does what it should

查看:103
本文介绍了asp.net问题与回发后F5,因为它做什么,它应该的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个细节,就可以了列表视图Web表单,用户在详细视图领域填充数据,然后presses保存按钮,一切正常的时刻。

I have a web form with a detail and a list view on it, the user fills the data in the fields of the detail view and then presses the "save" button, and everything is ok for the moment.

但是,如果他们preSS <大骨节病> F5 后,该操作的新纪录会在数据库中插入,因为回传被重复。

However, if they press F5 after this operation a new record is going to be inserted in the DB, because the postback is repeated.

有谁知道这是如何能够避免?

Does anybody knows how this could be avoided?

推荐答案

这将是一个使用它的操作的POST请求任何网页一样。

This will be the same for any webpage that uses a POST request for its operations.

您可以通过使用的Response.Redirect(yourpage.aspx)您的保存按钮事件之后停止此。这将它们发送到你的页面的新版本,而不发布数据在里面。

You could stop this by using Response.Redirect("yourpage.aspx") after your save button event. This will send them to a fresh version of your page without post data in it.

这样做,这将是你的表单包含某种autheticity道理,比如生成的GUID的另一种方式。你可以处理一个请求使用GUID尚未发出之前保存请求之前做一些检查。

Another way of doing it would be for your form to include some sort of autheticity token, such as a generated GUID. You could do some checking before processing the save request that a request using that GUID has not been issued before.

这篇关于asp.net问题与回发后F5,因为它做什么,它应该的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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