Friday 22 April 2016

Configuring Sql Session State


Open a command prompt and locate the following path: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 based on your OS version and .NET version
Use the following statement:
Using default ASPState database and SQL security

aspnet_regsql -S serverName -U UserName -P Password -ssadd -sstype p

Using default ASPState database and windows security

aspnet_regsql -S serverName -E -ssadd -sstype p

Using custom database and SQL security

aspnet_regsql -d TableName -S serverName -U UserName -P Password 
-ssadd -sstype c

t - Stores session data in the SQL Server tempdb database. This is the default. If you store session data in the tempdb database, the session data is lost if SQL Server is restarted.
p - Stores session data in the ASPState database instead of in the tempdb database.
c - Stores session data in a custom database. If you specify the c option, you must also include the name of the custom database using the -d option.
In your configuration file:

Using default SQL security:

<sessionstate mode="SQLServer" timeout="20" allowcustomsqldatabase="true"sqlconnectionstring="Data Source=Server;User ID=UserID;Password=Password;"       cookieless="false">

Using default windows security:

<sessionstate mode="SQLServer" timeout="20" allowcustomsqldatabase="true"  sqlconnectionstring="Data Source=Server;Integrated-Security=SSPI;" cookieless="false">

Custom database name:

<sessionstate mode="SQLServer" timeout="20" allowcustomsqldatabase="true"sqlconnectionstring="Data Source=Server;Initial Catalog=tablename;User ID=UserID;Password=Password;" cookieless="false">

No comments:

Post a Comment

Search Keyword