user2584307
user2584307

Reputation: 78

VS2012 MVC - why my session was fixed whenever I build the project for debug

I am using VS2012 to make ASP.NET MVC4 However, I found my localhost:xxx (after Debugging and the website popped-up) always keep in a fixed session. For example, I login at a dummy account : 123, then the website will remain login as 123 whenever I re-build the project or even close the VS2012 and open next time.

Is that any session stored in my VS2012???

Thanks.

Upvotes: 0

Views: 399

Answers (1)

user2584307
user2584307

Reputation: 78

Solution:

There are different session states in ASP.NET http://msdn.microsoft.com/en-us/library/ms178586(v=VS.80).aspx

In-Process Mode The defaul one is <sessionState mode="InProc" timeout="10" />, the session will be clear after rebuild the project

State Server Mode we can use this, but remember to turn the services - ASP.NET State Service

<sessionState mode="StateServer"
  stateConnectionString="tcpip=localhost:42424"
  sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
  cookieless="false"
  timeout="2"
/>

SQL Server Mode we can use this after create a DB ASPSate by command, pls check this site for details - http://www.brianstevenson.com/blog/aspstate-concurrently-running-for-net-1011-and-net-20

<sessionState mode="SQLServer"
  stateConnectionString="tcpip=localhost:63586"
  sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
  cookieless="false"
  timeout="2"
/>

The session in State Server Mode & SQL Server Mode will not be cleared after rebuild the project, it's good for development

Upvotes: 1

Related Questions