防止重新提交浏览器刷新数据 [英] Preventing Re-submission of data on Browser Refresh

查看:74
本文介绍了防止重新提交浏览器刷新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格.提交按钮后,它将在数据库中插入一条记录.如果我返回浏览器并刷新页面,则会重新提交该页面,这会导致各种问题,您可以想像.如何确保用户无法刷新上一页,并且该页面的状态是否在刷新时又自动提交?

1.不,Response.Redirect无法解决此问题.用户仍然可以使用浏览器的后退"按钮返回并在提交时刷新,并且仍将运行该按钮的事件,将数据下游发送到我的DL插入
2.我尝试过Postback也不起作用.
3.如何使用会话.请帮助我,我是新来的人.所以请帮助我进行编码.

I have a form. On submit of a button, it inserts a record into the db. If I go back in my browser and refresh the page it''s resubmitting it causing all sorts of issues as you can imagine. How do I ensure that the user can''t refresh the previous page and the state of that page does another automatic submit on refresh like this?

1. No, Response.Redirect does NOT solve this problem. The user can still go back with the browser''s back button and refresh at the point where they submitted and it will still run the button''s event sending the data downstream to my DL insert
2. I tried Postback also its not working.
3. How to do it using session. Please help me i am new to this.So please help me with coding.

推荐答案

看看类似的问题..
在asp.net中重新提交页面刷新页面 [ ^ ]
Have a look on similar issue..
resubmission of page on page refresh in asp.net[^]


使用IsPostBack属性

Use IsPostBack property

if (!_page.IsPostBack)
{
//do your stuff here.
}



会话状态也为:

关注:在ASP.NET中检测刷新或回发 [ ^ ]



Also with Session state as :

Follow : Detecting Refresh or Postback in ASP.NET[^]

if ((bool)HttpContext.Current.Items["IsRefresh"])
{
//means refresh 
}
else
{
// means post back
}


这篇关于防止重新提交浏览器刷新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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