Losing session data in ASP.NET

By default Response.Redirect terminates thread execution and there might be a race conditions in setting session variables. It is described in article Don't redirect after setting a Session variable (or do it right), so try to use another, less violent version:

Response.Redirect("cpanel.aspx", false);

如果需要troubleshooting的话,可以打印HttpContext.Current.Session.SessionID来验证

另外如果代码中,重置了session的话。也会导致session中的数据丢失

Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", string.Empty));

最新文章

  1. IIS安装时,添加/编辑应用程序扩展名映射 确定按钮不可用。
  2. oracle错误码
  3. Sorl之.net操作
  4. ASUS K751笔记本电脑使用U盘启动
  5. C#编程实现Excel文档中搜索文本
  6. 键盘事件与JS Filter
  7. C - Virtual Friends
  8. 结构-行为-样式-angularJs ngAnimate(Js实现)
  9. Codeforces 986D Perfect Encoding FFT 分治 高精度
  10. 在linux上安装tomcat
  11. AS 自定义 Gradle plugin 插件 案例 MD
  12. vue2.0跨域携带cookie和IE兼容
  13. Redis主从同步分析(转)
  14. onsubmit解惑
  15. ubuntu16.04编译安装mysql5.7
  16. linux shell 删除指定文件夹下面 名称不包含指定字符的文件
  17. sublime3下载安装及常用插件、浏览器预览设置
  18. Nginx + Tomcat7 + redis session一致性问题
  19. Hadoop实战:reduce端实现Join
  20. 【Matlab】调试基础

热门文章

  1. [HDU2294]Pendant
  2. Sqlachemy的警告SAWarning: The IN-predicate on "sns_object.BIZ_ID" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.
  3. SelfCert wcf中 生成x5.09证书的工具
  4. 如何理解c++迭代器(上)
  5. VB - 错误处理
  6. C++中一个类(非继承类)对象,所占内存空间大小
  7. 一些关于SEO优化的笔记
  8. python基础--冒泡排序
  9. go 发送http请求
  10. .net core swagger汉化