Configure sqlserver session state on asp.net
Configure Database
Run the commad prompt.
Switch to the following location on command prompt.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Run aspnet_regsql command.
You will be presented with a wizard to install the necessary objects on the database to enable your database to store session related data from your asp.net application. You can use the same database that you are using for the application to store session data.

Click Next to continue……….
Select the option “Configure SQL server for application services”. and click Next.
Another option removes the application services from the database if you have previously installed the application services. Since you are going to add services click the first option.

Now provideĀ the database server, provide valid user name and password and select the database schema and click next to continue…..

Click next to confirm.

Finally got the success screen.

The above wizard configures sqlserver database that stores information for asp.net application services(membership, profiles, roles,personalization, sql web event provider).
If you want to add additional features for sqlserver session state, use command line options as below.
aspnet_regsql -ssadd -U sa -P sa -S localhost\sqlexpress -d databasename -sstype c
Configure on the web.config
Now time to configure on web.config. Configure the session state mode to sqlserver and provide the valid connectionstringname.
Example shown on the following snapshot.

Now your application is sqlserver session mode enabled. Now you will not be logged out every time when u change your code.This saves your lots of time while debugging your application if your application is session dependent.






