Asp.Net HttpApplication请求管道与Session(二)
2015-11-19 14:36
603 查看
Asp.Net 回话的创建与结束
1.第一次打开浏览器访问
2.添加Session数据后访问
3.关闭浏览器,再次打开访问
4.步骤跟踪
LogHelper.LogHelper _log = new LogHelper.LogHelper(); /// <summary> /// 程序开始----隐藏事件 /// </summary> protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); _log.WriteLine("程序开始"); } /// <summary> /// 程序结束----隐藏事件 /// </summary> protected void Application_End() { _log.WriteLine("程序结束"); } /// <summary> /// 回话开始----隐藏事件 /// 当用户指定浏览器第一次访问网站 创建 ASP.NET_SessionId 回话开始, /// 当用户关闭浏览器,再次使用相同浏览器访问网站,重新创建 ASP.NET_SessionId 新的回话开始 /// </summary> protected void Session_Start() { _log.WriteLine("回话开始,count=" + Session.Count + ",回话ID:" + Session.SessionID); StringBuilder builder = new StringBuilder(); foreach (string item in Session.Keys) { string line = string.Format("---{0}:{1}", item, Session[item]); builder.AppendLine(line); } _log.WriteLine(builder.ToString()); } /// <summary> /// 回话结束----隐藏事件 /// 当程序结束,清除服务器所有的回话ID,每个回话ID的删除都会触发该事件 /// 在同一个回话ID中,只能访问当前回话中创建的Session 数据 /// </summary> protected void Session_End() { _log.WriteLine("回话结束,count=" + Session.Count + ",回话ID:" + Session.SessionID); StringBuilder builder = new StringBuilder(); foreach (string item in Session.Keys) { string line = string.Format("---{0}:{1}", item, Session[item]); builder.AppendLine(line); } _log.WriteLine(builder.ToString()); }
1.第一次打开浏览器访问
2.添加Session数据后访问
3.关闭浏览器,再次打开访问
4.步骤跟踪
相关文章推荐
- webrtc 丢包反馈之 rtcp goog-remb
- OpenStack Neutron网络里使用VLAN, VXLAN和GRE要注意什么
- 判断网络是否可用
- TCP协议中的三次握手和四次挥手(图解)
- cdh安装-httpd安装
- 软件介绍(apache lighttpd nginx)
- Asp.Net HttpApplication请求管道与Session(一)
- 聊聊HTTPS和SSL/TLS协议
- HttpWebRequest的使用之Get和Post的差别(C#)
- 理解HTTP headers之Expires、Cache-Control、IF-Modified-Since
- 多线程中栈空间的分配 http://biancheng.dnbcw.info/linux/303270.html
- Asp.Net HttpApplication 事件汇总
- Linux线程之线程栈 http://blog.chinaunix.net/uid-22590270-id-3673013.html
- 携程tcp架构分析
- Zabbix 默认网络发现模板修改(第三篇)
- HTTP:好好理解HTTP协议---字节写HTTP协议
- HttpURLConnection-Get方法实现
- HttpURLConnection-Post方法实现
- 获取网络连接字符串-模板代码
- 网络嗅探器