If you find that you have multiple servers that need to share session state, storing it in the ASP.NET process memory will not work. For example you may deploy into a web-farm environment with a load balancer that distributes requests in a round-robin fashion. In this environment a single user's requests could be served by multiple servers.
In the web.config file you can configure a SQL server session store.
<configuration> <system.web> <sessionState mode="SQLServer" sqlConnectionString="Data Source=localhost;Integrated Security=SSPI" cookieless="true" timeout="30" /> </system.web> </configuration>
To create the sql schema use the aspnet_regsql tool. [SampleSqlServerName] is the hostname of the SQL server. -ssadd tells the tool to create the session state database. -sstype p tells the tool to create a new database with the default name ASPState.
aspnet_regsql.exe -S [SampleSqlServerName] -U [Username] -P [Password] -ssadd -sstype p