由网友(再美好也经不住遗忘啊i)分享简介:我想在我的ASP.NET MVC应用程序中使用会话变量。I'd like to use session variables in my ASP.NET MVC application.我已经添加了<的sessionState> 的标签我的web.config 文件中像这样I already added...
我想在我的ASP.NET MVC应用程序中使用会话变量。
I'd like to use session variables in my ASP.NET MVC application.
我已经添加了<的sessionState>
的标签我的web.config
文件中像这样
I already added the <sessionState>
tag in my web.config
file like this
<sessionState mode="InProc" cookieless="false" timeout="20">
</sessionState>
我在我的网址是这样获得的会话ID,如果我用无cookie =真正的
http://localhost:2967/%28S%28hcawmi55zoruuy453fbo3k55%29%29/RmdReqBankAccount
不过,我仍然无法在我的应用程序中使用会话变量。
But I still can't use session variables in my application.
我这样设置的变量在我的登录方式:
I set the variable like this in my login method:
Session["username"] = userName;
和我找回它像这样
string user_id = (string)Session["username"];
我得到试图检索值时,一个空字符串。
I get an empty string when trying to retrieve values.
推荐答案
固定,看来我写了一组会话变量时,错误的位置。
Fixed , it seems I got the wrong location when writing the set session variables.
相关推荐
最新文章