关于Session使用清空问题
需要做一个网站定时报警的功能,每一个网页需要公用同样的数据,因为如果在a页面取消了一条信息的显示,在b页面就不能显示 将数据要及时更新 所以想到了Session 在任意时候修改都能得到统一的数据,我写了timer让它定时执行清空Session 的方法 可是session无法使用
代码如下,理论上是可以的啊:
Asp.net代码
public void mytimer()
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.AutoReset = true;
timer.Enabled = true;
timer.Interval = 10 * 60 * 1000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(resettime);
timer.Start();
}
void resettime(object sender, System.Timers.ElapsedEventArgs e)
{
Session["powerOffID"] = "";
Session["speedOverID"] = "";
Session["hiJackID"] = "";
Session["time"] = minutes % 60;
}
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- JQuery+Asp.net MVC实现用户名重名查询
- .NET设计模式:工厂方法模式(Factory Method)[1]
- Web Service学习笔记(4)
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注
- 聊聊.net程序设计——浅谈使用VS2010建模拓展(下
- .net架构的最后思考(箴言)
- .NET简谈互操作(四:基础知识之Dispose非托管内存
- MVC3+Entity Framework 实现投票系统(二)
- asp.net DataTable和Dataset序列化成Json格式
- 使用ASP.NET MVC3+EF+Jquery制作文字直播系统(四



