asp.net - In a multi web server farm, how does session state work? -
case 1: stateserver
<system.web> <sessionstate mode="stateserver" stateconnectionstring="tcpip=127.0.0.1:42626" sqlconnectionstring="data source=127.0.0.1;trusted_connection=yes" cookieless="false" timeout="20" /> ... </system.web>
case 2: sql server
<sessionstate mode="sqlserver" stateconnectionstring="tcpip=127.0.0.1:42626" sqlconnectionstring="data source=127.0.0.1;trusted_connection=yes" cookieless="false" timeout="20" />
question: 1. in case 1 , 2 appropriate location of sql or state server have configured in web.config each of web server in farm.
can have servers configured state , sql?
can have cookieless , withcookie
suppose if use
<sessionstate cookieless="true" />
, default of modes used? can done in multiserver farm, or necessary specify ip?
1.) can have servers configured state , sql?
no, should not. suppose when user makes request, 1 of server web farm store session in stateserver. in case same user makes request ( clicking links etc...), image happen if load balancer send request 2nd web server ? there no session same user configured sqlserver mode same , session user stored on state server on first request.
2.) can have cookieless , withcookie ?
again no, similar understanding pointed above. 1 of server use cookies track session , other 1 cookieless ( hence uri ) track same session , thus, if request gets forwarded different servers, no session detected.
3.) suppose if use <sessionstate cookieless="true" />
, default of modes used? can done in multiserver farm, or necessary specify ip?
understand setting: cookieless="true|false"
, used track session particular user between client side , server side.
the actual session data there stored on sqlserver/state server, defined in mode settings as:
<sessionstate mode="stateserver|sqlserver" ... />
if don't specify mode
setting, default value of inproc
used.
additional note: cookie or uri have sessionid
associated them. sessionid
unique string, used track individual visitor between visits website.
as result of cookieless="true"
, sessionid
embedded in page urls. drawback you'll end ugly urls, not seo (search engine optimization) , visitor not remember it. here example url of website uses asp.net cookieless sessions:
http://samplewebsite.com/(45f8c4zyybphaw2mt3dfgnjk4j)/home.aspx
bolded part represents session id, used recognize visitor.
Comments
Post a Comment