SessionState stateConnectionString and sqlConnectionString

10,165

AFAIK you can skip the StateConnectionString when storing sessionstate in SQL Server.

I haven't tried it, but it seems to be confirmed here: http://support.microsoft.com/kb/317604

Share:
10,165
LCJ
Author by

LCJ

.Net / C#/ SQL Server Developer Some of my posts listed below -- http://stackoverflow.com/questions/3618380/log4net-does-not-write-the-log-file/14682889#14682889 http://stackoverflow.com/questions/11549943/datetime-field-overflow-with-ibm-data-server-client-v9-7fp5/14215249#14215249 http://stackoverflow.com/questions/12420314/one-wcf-service-two-clients-one-client-does-not-work/12425653#12425653 http://stackoverflow.com/questions/18014392/select-sql-server-database-size/25452709#25452709 http://stackoverflow.com/questions/22589245/difference-between-mvc-5-project-and-web-api-project/25036611#25036611 http://stackoverflow.com/questions/4511346/wsdl-whats-the-difference-between-binding-and-porttype/15408410#15408410 http://stackoverflow.com/questions/7530725/unrecognized-attribute-targetframework-note-that-attribute-names-are-case-sen/18351068#18351068 http://stackoverflow.com/questions/9470013/do-not-use-abstract-base-class-in-design-but-in-modeling-analysis http://stackoverflow.com/questions/11578374/entity-framework-4-0-how-to-see-sql-statements-for-savechanges-method http://stackoverflow.com/questions/14486733/how-to-check-whether-postback-caused-by-a-dynamic-link-button

Updated on June 04, 2022

Comments

  • LCJ
    LCJ almost 2 years

    We want to store session in SQL Server. We have sessionState mode="SQLServer". I have been given a sample connectionstring as listed below. In this it is having both stateConnectionString and sqlConnectionString.

    Question: Why do we need stateConnectionString when mode="SQLServer"?

    <sessionState mode="SQLServer" 
    cookieless="false" timeout="20" 
    stateConnectionString="tcpip=XXX.XX.XXX.XXX:42424" 
    sqlConnectionString="data source=XXX-FFFF-sql2k8,2025;
    Initial   Catalog=AspState_XX_3_0;user id=XXX;password=XXX" 
    allowCustomSqlDatabase="true" 
    sqlCommandTimeout="1200"/>
    

    Note 1: SQLServer mode stores session state in a SQL Server database. Using this mode ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm. To use SQLServer mode, you must first be sure the ASP.NET session state database is installed on SQL Server. You can install the ASP.NET session state database using the Aspnet_regsql.exe tool

    Note 2: StateServer mode stores session state in a process, referred to as the ASP.NET state service, that is separate from the ASP.NET worker process or IIS application pool. To use StateServer mode, you must first be sure the ASP.NET state service is running on the server used for the session store. To use StateServer mode in a Web farm, you must have the same encryption keys specified in the machineKey element of your Web configuration for all applications that are part of the Web farm.