刷新页面集PostBack = true [英] Refresh of Page set PostBack = true

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

问题描述

我的asp.net项目中有一个aspx页面,其中有一个按钮控件 单击按钮,然后使用F5键或浏览器的刷新按钮刷新页面后,而不是将IsPostBack属性设置为false,而是将其设置为true.

I have one of a aspx page in my asp.net project which has a button control after clicking on the button and then refreshing the page using F5 key or refresh button of the browser, instead of setting IsPostBack property to false, it is setting it to true.

有人可以帮我吗?

推荐答案

单击该按钮将触发该表单的HttpPost,并将其发布到同一页面,这称为回发.刷新页面会触发最后执行的操作,在这种情况下,该操作是发布.大多数浏览器在刷新发布的页面时都会向用户发出警告.

Clicking the button triggers a HttpPost of the form and it's posted to the same page, which is what's called a post back. Refreshing the page triggers the last executed action, which in this case was a post. Most browsers warn the user about this when they refresh a posted page.

如果您不希望出现这种情况,则必须确保在发布后执行get操作(所谓的发布后重定向/发布后获取"技术).

In case you don't want this behaviour you have to make sure that you perform a get operation after the post (the so called "Redirect after post/Get after post"-technique).

实现此目标的一种方法是使用以下命令结束回发操作:

One way of achieving it is to end the post back action with:

 Response.Redirect(Request.RawUrl);

这篇关于刷新页面集PostBack = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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