简体   繁体   中英

understanding Session State Mode c#

I am creating a web app in asp.net mvc in my web.config I have a section called sessionState, like below

<sessionState mode="InProc" timeout="25"></sessionState>

whenever I change the mode to InProc , I can use sessions but when I changed the mode to StateServer I am not able to use sessions, after searching on google, I came to know that there are 5 types of sessionstates

InProc

StateServer

SQLServer

Custom

Off

I just want to know, in which scenario the above sessionstate can be used,

InProc - runs as part of your website / web application, always there, but only on the same server and on the same instance of the website.

StateServer - need to run this service on a machine (just press start :-)), so the session can connect to that process on that machine and can be shared between instances and servers.

SQLServer - same as stateserver, but using a SQL database for this.

Custom - any stateserver you program yourself.

Off - no session tracking.

Whilst session can make a lot of things easier for development, when you get to a multi-server deployment this becomes a hassle. So make sure to limit session usage, always being able to retrieve the session data if this is no longer available, that way you can get the best of performance using the session, whilst your app still keeps working if your session is no longer there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM