在ASP.NET中单击“浏览器刷新"(F5)按钮后,将发生回发. [英] In ASP.NET After clicking on Browser Refresh(F5) button postback happens .

查看:112
本文介绍了在ASP.NET中单击“浏览器刷新"(F5)按钮后,将发生回发.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序运行良好.但是,当我单击浏览器时,Refersh(F5)按钮回发发生.如何避免在asp.net中发回邮件.

谢谢,
Mangesh B.

My application working well. but when i click browser Refersh(F5) button postback happens. How do i avoid this postback in asp.net.

Thanks,
Mangesh B.

推荐答案

这是网络的工作方式.如果您的最后一个操作是POST,则F5重复该操作.解决方法是每次回发都设置页面呈现其自身所需的状态(因此viewstate中没有内容)并做出响应.重定向到页面.由于URL和会话中的值,这会将POST转换为GET,F5将执行GET并呈现页面,页面将以您请求的状态呈现.
This is how the web works. If your last action was a POST, F5 repeats it. The way around it is for every postback to set up the state needed for your page to render itself ( so nothing lives in viewstate ) and doing a response.Redirect back to your page. This turns the POST into a GET, and F5 will do a GET, and render the page, which will render in the state you requested, because of values on the URL and in the session


这是由于浏览器的工作方式.预览刷新只是重复上一个请求.示例:第一次发布页面时,浏览器发送所有数据,然后返回HTML进行渲染.如果您单击刷新(F5),则浏览器将重新发送上一个POST请求,从而再次发送信息.您无法避免回发,但是可以根据需要找到并处理.

在此处查看一些提示:
ASP.Net中的刷新页面问题 [提交请求后,请刷新 [检测页面刷新 [
This is due to how browsers work. Preseeing Refresh just repeats the last request. Example: The first time you POST the page, the browser sends all the data, then returns back HTML to render. If you hit refresh (F5) then the browser re-sends the last POST request thus re-sending the information again. You cannot avoid the postback but can find and handle it if you want to.

See few tips here:
Refresh Page Issue in ASP.Net[^]
Stop Refresh after Submitting your Request[^]
Detecting Page Refresh[^]


这篇关于在ASP.NET中单击“浏览器刷新"(F5)按钮后,将发生回发.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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