惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Stack Overflow Blog
Stack Overflow Blog
Forbes - Security
Forbes - Security
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
S
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
N
News | PayPal Newsroom
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Google Online Security Blog
Google Online Security Blog
Simon Willison's Weblog
Simon Willison's Weblog
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
T
Tenable Blog
I
InfoQ
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
D
DataBreaches.Net
博客园 - Franky
Know Your Adversary
Know Your Adversary
Spread Privacy
Spread Privacy
S
Security @ Cisco Blogs
Hacker News: Ask HN
Hacker News: Ask HN
J
Java Code Geeks
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Full Disclosure
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
I
Intezer
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
F
Fortinet All Blogs
Jina AI
Jina AI
V
Visual Studio Blog
L
LINUX DO - 热门话题
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏

博客园 - 网风

ASP.NET Forums技术研究 关于触发器:在Sql2000中获取针对一个数据库的所有触发器 Sql2000中的规则具体怎么样使用 Sql2000中的角色与用户之间的处理关系 Sql2000中事务处理之事务保存点与嵌套事务 case的深入用法 在游标中进行事务的处理 Sql2000中的分布式事务 使用临时表与声明一个表数据类型的变量有什么区别 Oracle9i安装问题系列 蜘蛛程序参考资料 使用全局唯一标识(GUID) .net的体系结构运用到系统上 经验谈一 Codesmith模板开发 Sql技巧集 项目体系结构 本周研究主题--.net企业库使用 本周技术主题-----.net中的资源文件
同一个页面同时多次保存的解决方案
网风 · 2006-06-02 · via 博客园 - 网风

习惯的解决方法是存储Session的ID和当提交时ViewState中存储的SessionID相比较来防止用户刷新屏屏幕。前提你的程序中允许了自动回发,如果不是的话,就得在hidden field存储这个变量了。下面给出一个典型的例子。在Page_Load事件中你存储了第一次提交时的SessionID和一个时间戳。
protected System.Web.UI.WebControls.Button SubmitButton;

protected System.Web.UI.WebControls.Label RefreshID;     

private void Page_Load(object sender, System.EventArgs e)

{
     if (RefreshID.Text.Length == 0) 
    {
            RefreshID.Text = Session.SessionID+DateTime.Now.Ticks.ToString();
      }
}
 

private void Button1_Click(object sender, System.EventArgs e)

{
      string sesToken = (string) Session[FrameworkConst.SYNC_CONTROL_KEYWORD];      string pageToken = RefreshID.Text;
      if (sesToken != null && sesToken != pageToken)
      {
            Response.Write("The Refresh was performed after submit.");
     } 
      else
      {
            // do your processing here to avoid Refresh trap
            Response.Write("The processing is done here. Disabling submit
button so that user can not perform multiple submit.");
            Response.Write("But still user can peform Refresh on page.");
      }

      Session[FrameworkConst.SYNC_CONTROL_KEYWORD] =       Session.SessionID+DateTime.Now.Ticks.ToString();
      RefreshID.Text = sesToken;         
      SubmitButton.Enabled = false;