asp.net mvc enabling session state

Posted by Erwin on Stack Overflow See other posts from Stack Overflow or by Erwin
Published on 2010-04-12T07:37:59Z Indexed on 2010/04/12 7:43 UTC
Read the original article Hit count: 1045

Filed under:
|

Hi fellow programmer

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

I already added tag in my web.config file like this

        <sessionState mode="InProc"
                          stateConnectionString="tcpip=127.0.0.1:2967"
                          sqlConnectionString="data source=127.0.0.1;trusted_connection=true"
                          cookieless="false"
                          timeout="20" />

But I still can't use session variables in my application

I set the var like this in my login method

Session["username"] = userName;

and retrieve it like this

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

I got null string when retrieving.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about session-state