如何防止重复的回发混淆我的业务层 [英] How to prevent repeated postbacks from confusing my business layer

查看:112
本文介绍了如何防止重复的回发混淆我的业务层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有常规3层设计的Web应用程序(ASP.Net 3.5)。如果用户点击按钮发生回发,则会运行一些中间和数据层代码,并刷新屏幕。如果用户在第一次回发完成之前多次点击该按钮,我的逻辑就会变得困惑,应用程序可能会处于无效状态。
什么是最好的方式来防止这种情况?



我可以使用javascript禁用该按钮,但这只是隐藏了问题。如何构建我的业务和数据层来处理这个问题?

解决方案

三种最流行的方法(常常用于串联)是:


  1. 一旦点击/按下,禁用提交按钮;

  2. 使用 POST + REDIRECT + GET 以避免返回按钮问题;和

  3. 更换浏览器中的历史记录所以你不能回去(但这应该谨慎使用,有很好的理由)。


I have a web application (ASP.Net 3.5) with a conventional 3 layer design. If the user clicks a button a postback happens, some middle and data layer code runs, and the screen is refreshed. If the user clicks the button multiple times before the first postback is completed my logic gets confused and the app can end up in an invalid state. What are the best ways to prevent this?

I can use javascript to disable the button but this just hides the problem. How do I build my business and data layers to handle this?

解决方案

The three most popular methods (which are often used in tandem) are:

  1. Disable submit buttons once clicked/pressed;
  2. Use POST+REDIRECT+GET to avoid back button issues; and
  3. Replace history in the browser so you can't go back (but this should be used sparingly and with good reason).

这篇关于如何防止重复的回发混淆我的业务层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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