如何从用户是否preSS F5发送prevent数据或在asp.net中刷新? [英] how to prevent data from sending if user press F5 or refresh in asp.net?

查看:169
本文介绍了如何从用户是否preSS F5发送prevent数据或在asp.net中刷新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我asp.net形式应用程序我有,当用户点击F5或刷新它会从去年的数据输入中输入的数据。是他们的客场prevent发送数据,如果用户单击一下F5或刷新一个错误?

I had asp.net form app I have a bug when the user click F5 or refresh it will enter the data from last data entry .is their is away to Prevent sending data if user click click F5 or refresh?

推荐答案

这很容易给它的通过重定向到自己在ASP.NET初始状态重新设置的页面。这里有3种方式可以做到这一点:

It's easy to reset a page to it's initial state in ASP.NET by redirecting to itself. Here are 3 ways you can do it:


  1. 的Response.Redirect(Request的);

在该路径请求以下形式psented $ P $:/MyApp/MyFile.aspx

In which the path to the request is presented in the following form: /MyApp/MyFile.aspx


  1. 的Response.Redirect(Request.RawUrl);

在这不仅是露出的路径,但也可以是任何查询字符串参数,如:
/MyApp/MyFile.aspx?foo=bar

In which not only is the path exposed, but also any querystring parameters like: /MyApp/MyFile.aspx?foo=bar


  1. 的Response.Redirect(Request.Url.ToString());

在这不仅是路径和查询字符串参数曝光,但作为形式的绝对基准可用:
要播/ MyApp的/ MyFile.aspx?富=栏

In which not only is the path and querystring parameters exposed, but made available as an absolute reference in the form: MyServer/MyApp/MyFile.aspx?foo=bar

这篇关于如何从用户是否preSS F5发送prevent数据或在asp.net中刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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