把值放在会话中 [英] put values in session
问题描述
我有一些变量,现在我想查看会话中存在的价值
,将它们放在MVC会话启动的会话中。
我是MVC的新手任何有关这方面的帮助将不胜感激。
谢谢!
您可以检查是否有值正在进行会议..
if (会话!= null && Session [ value]!= yourValue)
{
// 代码
}
其中值是您的会话变量或 yourValue 是该变量的值。
这两个链接将清除您将值放入会话变量:
http://stackoverflow.com/questions/10123143/asp-net-mvc-3-dealing-with-session-variables [ ^ ]
http://stackoverflow.com/questions/ 560084 / session-variables-in-asp-net-mvc [ ^ ]
从我的观点来看,本教程是必须的:
MVC测试驱动开发:会话变量 [ ^ ]
<预lang =sql> if (!string.IsNullOrEmpty(Session [ value1] as string)&& !string.IsNullOrEmpty(Session [ value2] as string))
{
}
I have some variables and now I want to check for values
exist in session, put them in session on session start in MVC.
I am new to MVC and any help regarding this would be appreciated.
Thanks!
You can check whether a value is in session by..
if(Session != null && Session["value"] != "yourValue") { // code }
Where "value" is your session variable or "yourValue" is the value of that variable.
These 2 links will clear you about putting values in a session variable:
http://stackoverflow.com/questions/10123143/asp-net-mvc-3-dealing-with-session-variables[^]
http://stackoverflow.com/questions/560084/session-variables-in-asp-net-mvc[^]
And this tutorial is a must from my point of view:
MVC Test Driven Development: Session Variables[^]
if (!string.IsNullOrEmpty(Session["value1"] as string) && !string.IsNullOrEmpty(Session["value2"] as string)) { }
这篇关于把值放在会话中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!