Enabling Session State in ASP.NET MVC

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

I already added the <sessionState> to my web.config , like this

 <sessionState mode="InProc" cookieless="false" timeout="20"> </sessionState> 

I get the session id in my url, for example if I use cookieless="true"

 http://localhost:2967/%28S%28hcawmi55zoruuy453fbo3k55%29%29/RmdReqBankAccount 

But I still cannot use session variables in my application.

I set such a variable in my login method:

 Session["username"] = userName; 

and I get it like this:

 string user_id = (string)Session["username"]; 

I get an empty string when trying to get the values.

+2
source share
1 answer

Fixed, it looks like I got the wrong location when writing the given session variables.

0
source

Source: https://habr.com/ru/post/980930/


All Articles