views:

434

answers:

3

We're trying to get session state working using the following web.config line:

<sessionState 
    mode="SQLServer" 
    stateConnectionString="tcpip=127.0.0.1:42424" 
    sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password='thepassword'" 
    cookieless="false" 
    timeout="20"/>

On dbServer, we've run the following command to set up the ASPState db:

aspnet_regsql.exe -S localhost-E -ssadd -sstype p

On the webServer, we've started the ASP.Net state service, however, no records show up in tables ASPStateTempApplications or ASPStateTempSessions, and it seems very much like session is still being stored in process.

What's wrong? Should the state service be running on the DB server? Does it get installed with IIS, because it's not available on that machine, despite .net 3.5.1 being installed.

The IIS logs show no hint of failure. What's wrong?

+3  A: 

If there's really quotes around the password, try to remove them:

sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password=thepassword"

And remove the following line, it has no function for SQL session storage:

stateConnectionString="tcpip=127.0.0.1:42424"

And you might as well stop the state service; it's needed for out-of-process session state, not for SQL Server session state.

Also, SQL Server session state requires you to run InstallSqlState.sql on the database, not aspnet_regsql.exe. It should create a new ASPState database.

Andomar
I agree with this answer, except for the last line. **Do not** try to run InstallSqlState.sql by hand; it is designed to be run by aspnet_regsql.exe; there are even comments at the top of the file that say the same thing.
RickNZ
+1 for not requiring the state service. See comments under marcc's post to learn of my stupidity!
spender
+2  A: 

First, you don't need to start the State Service in order to use SQL Server session state. Forget about the ASP.NET State Service.

Are you sure that your site is creating a session variable? Just because you put these changes in your web.config, if you never use session variables, it won't be used.

marcc
Bingo. I was under the impression that session state also is responsible for maintaining forms authentication (I'm running a few servers under a balancer). Session state is indeed being saved (just unused on the pages I was testing). What I actually needed to do was set the same machineKey keys to preserve authentication as users are shunted between nodes of my farm. A severe case of RTFM.
spender
A: 

How about writing a small HttpModule? You could drop it into place for the period of time when you need to transition users to the new codebase. The module could do some work on each page request to check the user's session and decide whether it needs to be abandoned. Perhaps you store an application version string in the user's session when the session is first created and compare the current app version string against that.

Larry Silverman