asp.net mvc - MVC: session InProc vs Stateserver -


trying hunt down day.

i can sessions work if used "statesever". holds session controller controller , on refresh. if use "inproc" session lives controller controller on refresh dies [null]. timeout should not issue because run immediately.

any on appreciated. don't want use stateserver...at least until understand why happening.

web config

<!--<sessionstate cookieless="usecookies" timeout="1440" mode="inproc"/>-->   <sessionstate cookieless="usecookies" timeout="1440" mode="stateserver" stateconnectionstring="tcpip=127.0.0.1:42424"/> 

controllers

    public actionresult login()     {         system.web.httpcontext.current.session["sessionval"] = "test";         return view();     }      public actionresult loginsuccess()     {         return view();     } 

views

@{ layout = ""; } <h2>login</h2> <a href="/login/loginsuccess">go here</a> 

2nd view

@{ layout = null; } session:  @session["sessionval"] 

i disabled session state in web config. put datetime in session first time run project displays session. hit f5 , remakes session. continue hit f5 , holds. enabled stateserver , same process never remakes session on first refresh.

by default, sessionstate inproc mode. inproc means session stored in memory on web server. if debug in visual studio, local computer's memory.

since memory not persistent storage, sessionstate clearned garbage collector application stopped.

the bottom line it design , there nothing can it.

if want persistent sessionstate after application stopped, need use stateserver or sqlserver.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -