开发者

Enabling Session State in ASP.NET MVC

开发者 https://www.devze.com 2022-12-26 05:37 出处:网络
I\'d like to use session variables in my ASP.NET MVC application. I already added the <sessionState> tag in my web.config file like this

I'd like to use session variables in my ASP.NET MVC application.

I already added the <sessionState> tag in my web.config file like this

<sessionState mode="InProc" cooki开发者_C百科eless="false" timeout="20">
    </sessionState>

I get a session ID in my url like this if I use cookieless="true"

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;

and I retrieve it like this

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消