Karan
Karan

Reputation: 1

Asp.Net Sql Server Session Management

I want to know if I have sqlstate session then do I need to create database for aspnetdb in the already (i.e. sampledb) existed database or I should have to create it separately. Suppose if I had create it in sampledb which is already existed then what connection-string path should I have to give in web.config and what changes would I have to make it on the time of deployment of the internet.

Please give me answer because there is lots of questions arising in my mind.

Upvotes: 0

Views: 64

Answers (1)

Denys Wessels
Denys Wessels

Reputation: 17029

You should create a new database for the session state.

Configuring SQL Server session state is really simple and requires two simple steps:

  1. Install ASPState database on your SQL server.

    1.1 Open the command prompt and navigate to the folder where .NET Framework is installed on your machine e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319

    1.2 Run the following command in the command prompt - aspnet_regsql.exe -S SampleSqlServer -E -ssadd -sstype p

  2. Configure SQL server session state in the Web.config file to point to the ASPState database on your server.

Web.config:

<configuration>
  <system.web>
    <sessionState mode="SQLServer"
      sqlConnectionString="Integrated Security=SSPI;data 
        source=SampleSqlServer;" />
  </system.web>
</configuration>

Complete tutorial can be found here - Session-State Modes

Upvotes: 1

Related Questions