Session在Controller中的传递
来源:互联网 发布:dnf怎么老是网络中断 编辑:程序博客网 时间:2024/05/22 03:40
最近遇到一个问题,就是Session在Controller中传递的时候是空值。
简单做了一个小Demo来验证这件事情。
<span style="font-size:18px;"> GetSessionController getSession = new GetSessionController(); public ActionResult Index() { Session["Session1"] = "小明"; //System.Web.HttpContext.Current.Session["Session2"] = "小红"; getSession.Index(); return View(); }</span>
<span style="font-size:18px;"> public ActionResult Index() { // string name2 = System.Web.HttpContext.Current.Session["Session2"].ToString(); string name = Session["Session1"].ToString(); return View(); }</span>
在一个Controller中调GetSessionController中的Index方法的时候,希望可以用Session来传值,但是,在GetSessionController中的session却获取不到相应的Session值。
暂时不明白mvc中为什么传递session会出现空值,我们引用session时默认引用的是System.Web.Mvc.Controll.session,可能这个session不能传递,所以解决方法就是详细定义session,我们可以定义System.Web.HttpContext.Current.Session可以解决这个问题
这个Session和System.Web.HttpContext.Current.Session问题先保留,我会去查明原因,也希望大家能够给我指点
0 0
- Session在Controller中的传递
- 关于mvc中的session在controller中传递
- 在VO中引用Controller层中的Session State的两种方法
- 在controller中获取不到的session值中的验证码问题
- 在controller和视图之间传递参数
- 将Controller中的数据传递到View中显示
- 关于SSM中的Controller传递参数的类型的问题
- 使用session在页面间传递参数
- SpringMVC框架在Controller中对于Session的处理
- 使用JQuery Ajax请求,在Controller里获取Session
- 使用springMVC框架时,怎样在controller里获得Session
- 多个controller切换以及在他们之间传递数据
- 利用协议在view controller之间传递数据
- springmvc在controller和视图之间传递参数
- 前端传递参数,在Controller显示问号乱码的问题?
- 在springMVC中的controller写单元测试
- 在页面上获取controller中的值
- 指针在函数中的传递
- 安卓控件Dialog
- c++地址问题
- 学习Java必看书籍和步骤
- python keras (一个超好用的神经网络框架)的使用以及实例
- Git
- Session在Controller中的传递
- android 中异步线程的实现方法
- 安卓布局,控件imageview,ListView
- 目标和计划
- Win7和CentOS 6.5 双系统安装注意事项
- 集群的概念及分类
- web开发的第一个小作品--html svg +css+js时钟效果
- MySQL绿色版的安装(mysql-5.6.22-win32/winx64.zip)
- Palindrome Linked List -- leetcode