Monday, September 16, 2013

SessionState using SQL Server

1. Install database scheme

C:\Windows\Microsoft.NET\Framework\v4.0.30319>

aspnet_regsql.exe -sstype c -ssadd -d DatabaseName -U username -P password  -S xx.xx.xx.xxx



2. Config

    < sessionState mode="SQLServer" sqlConnectionString="data source=DatabaseName ;user id=username ;password=password" cookieless="UseCookies" timeout="20"/>

Remember to give the user dbowner permission.

3.  ASP.NET Universal Providers

 ASP.NET Universal Providers that will extend Session, Membership, Roles and Profile support to SQL Compact Edition and SQL Azure. Other than supporting additional storage options, the providers work like the existing SQL-based providers.

    < sessionState mode="Custom" customProvider="DefaultSessionProvider" allowCustomSqlDatabase="true">
      < providers>
        < add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      < /providers>
    < /sessionState>

See here for detail about Azure config.

No comments: