How to configure SQL Server to use the SQL Server Session Management in ASP .NET?

aspnet_regsql usage for configuring your database for using it for Session State Management in .NET

Advertisements

ASP.NET offers three session management solutions. They are:

  • InProcess,
  • StateServer (outProcess),
  • SQLServer (based on the database)

Today I spent about 3 hours just to get the configuration right for using this third type called SQLServer based Session State Management. I ended up configuring it on SQL Server 2000,

Well, in short this is what my command looked like:-

aspnet_regsql -ssadd -S <Database Server Name> -U <DB User Name> -P <DB User’s Password>
Curious about the switches used here:
Over the application end, you need to make the following changes in your web.config file.
<system.web>

<sessionState mode=SQLServer sqlConnectionString=Data Source=DATABASE_SERVER_NAME;Initial Catalog=aspState;Persist Security Info=True;User ID=DBUSER_NAME;Password=DB_PASSWORD; allowCustomSqlDatabase=true >

</

 

</system.web>

Its very important that you set the allowCustomSqlDatabase=true” coz you wont be able to get it running without this — atleast that’s what I’ve learnt in the last 3-4 hours.

Hope that helps,

Happy programming!

 

Author: Imran Akram

A .NET/SharePoint Consultant and a political enthusiast who believes in putting the feet of the elected and/or unelected officials to fire in order to get good governance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s