At some point we need to store information when dealing with web application. Storing information in web application can be implemented in some ways such as session and cookies.
Dealing with session case, previously I never got a situation where I should store the session state in persistance way till I got a condition implementing this way.
The scenario is we want to implement load balancer to our applications and services (web service, wcf) that hosted in IIS. The aim of this enhancement basically to improve availability and scalability of existing in house application without doing huge refactoring.
In this post I just want to share the short steps I did during researching implementing session state on a database.
First of all open command prompt and navigate to .NET framework installation path. In this case, my installation path is
We will use a tool called
aspnet_regsql.exe that shipped with .NET framework installation to generate database that will be used to store session state. To display detail argument needed by this tool we can use the following command:
The command will create database, tables and store procedures. In web.config, don’t forget to add session state configuration by pointing the generated database.
1 2 3 4 5
To test our session storage, just create simple aspx page.
1 2 3 4 5 6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17