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

推荐订阅源

有赞技术团队
有赞技术团队
量子位
B
Blog RSS Feed
Schneier on Security
Schneier on Security
L
LINUX DO - 最新话题
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
N
News | PayPal Newsroom
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
PCI Perspectives
PCI Perspectives
aimingoo的专栏
aimingoo的专栏
D
Docker
T
The Exploit Database - CXSecurity.com
Last Week in AI
Last Week in AI
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
Vercel News
Vercel News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
O
OpenAI News
C
Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Help Net Security
Help Net Security
Scott Helme
Scott Helme
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
V
V2EX
P
Proofpoint News Feed
Simon Willison's Weblog
Simon Willison's Weblog
A
About on SuperTechFans
S
Securelist
G
Google Developers Blog
Cyberwarzone
Cyberwarzone
The GitHub Blog
The GitHub Blog

博客园 - 网风

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;