Knowledge
  • Read Me
  • Programming
    • ASP.NET
      • .NET Libraries
      • ASP.NET Core
        • Helper
          • Encryption
          • CSV Helper
          • String Helper
        • Logging
          • Simple Serilog
        • Middlewares
          • IP Restrictions
          • Request Throttling
          • Request Logging
        • Console
          • Command Line with arguments
        • JSON
      • ASP.NET Framework
      • Testing
        • Resources
        • xUnit.net
      • Naming Conventions
      • REST API Guidelines
    • Database
      • SQL Style Guide
      • MSSQL
        • Installation
          • Install MSSQL on MacOS M1 (ARM64)
        • Looping
        • Table Valued Functions
        • Session State
        • SQL Cheat Sheet
        • Export Pipe Delimited CSV With cmdshell
      • Redis
        • Redis Installation on Mac OS
        • Redis Installation on Docker
    • Java
      • AWS SDK - SSM
      • mTLS HTTP Connection
      • Read Resource Files
    • Javascript
      • Javascript Libraries
    • Python
    • OpenSSL
      • One Way SSL & Two Way SSL
      • Common OpenSSL Commands
      • Create Self-Signed Certificate
    • Misc
      • Git Commands
      • Windows Commands
      • PowerShell Commands
      • Vulnerabilities Dependency Check
      • Replace Filename Command
      • JSON Web Token (JWT)
      • Rabbit MQ Message-Broker
      • Pandoc Convert Document
  • DevOps
    • What is DevOps
    • CI & CD
    • Azure DevOps
  • Tools
    • Development Tools
Powered by GitBook
On this page
  • Step 1
  • Step 2
  • Step 3

Was this helpful?

  1. Programming
  2. Database
  3. MSSQL

Session State

Step 1

Update the web.config

  • mode: SQLServer

  • allowCustomSqlDatabase: true (if create a custom database name)

  • sqlConnectionString: server={server};database={database};uid={username};pwd={password}

<sessionState 
  customProvider="DefaultSessionProvider" 
  mode="SQLServer" 
  allowCustomSqlDatabase="true"
  sqlConnectionString="server=localhost;database=ASPState_Testing;uid=sa;pwd=password">

Step 2

In the MSSQL, created a database named 'ASPState_Testing' (for this example).

Step 3

Run 'aspnet_regsql.exe' using command prompt with following command line

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql -d <Databse> -S <Server> -U <Username> -P <Password> -ssadd -sstype c

# Example
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql -d ASPState_Testing -S localhost -U sa -P password -ssadd -sstype c
PreviousTable Valued FunctionsNextSQL Cheat Sheet

Last updated 6 years ago

Was this helpful?