The ASPStage (ASP.NET Session State) provides you the option to store website session data to the SQL server database. This is a useful option with load balancing, where application deployment is on multiple servers. This tutorial will help you to create an ASPState database in SQL server with the command line.
Prerequsities
You must have installed the .net framework on your system to complete this task.
Create ASPState Database
After installing the .net framework on your system, open the windows command prompt and navigate to the framework installation directory as per your installed version of the .net framework and system architecture.
Syntax:
aspnet_regsql.exe -ssadd -sstype p -S {SQL Instance} -U {Username} -P {Password}
Implementation:
Navigate to the .net framework directory as followings:
c:\> cd "%windir%\Microsoft.NET\Framework64\v4.0.30319"
Directory path may be changed as per your installation like below.
.NET Framework 2.0/3.0/3.5 (32-bit): %windir%\Microsoft.NET\Framework\v2.0.50727 .NET Framework 2.0/3.0/3.5 (64-bit): %windir%\Microsoft.NET\Framework64\v2.0.50727 .NET Framework version 4.x (32-bit): %windir%\Microsoft.NET\Framework\v4.0.30319 .NET Framework version 4.x (64-bit): %windir%\Microsoft.NET\Framework64\v4.0.30319
Now execute following command to finally create database named ASPState in SQL server defined instance. As per below command DB1SQLEXPRESS is my SQL instance.
aspnet_regsql.exe -ssadd -sstype p -S DB1SQLEXPRESS -U sa -P myPassword
On successful execution of the above command, you will get output like below.
Microsoft (R) ASP.NET SQL Registration Tool version 4.0.30319.33440 Administrative utility to install and uninstall ASP.NET features on a SQL server. Copyright (C) Microsoft Corporation. All rights reserved. Start adding session state. ......................... Finished.
2 Comments
Thanks! it’s helpful to us
Thanks Rahul.. nice post