Click here to Skip to main content
11,646,648 members (77,328 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
How to configure session state for 'SqlServer' Mode in Web.config


I tried the following but iam getting error please help me on this, Thanks in advance.

Web.Config:
<system.web>
        <compilation debug="true" targetFramework="4.0" />
      <sessionState cookieless="false" mode="SQLServer"  sqlConnectionString="Data Source =localhost;Initial Catalog =sample;User ID = VIGNESHJ\Admin;password=viki;Integrated Security=true;"></sessionState>
 </system.web>

Error:
 
Server Error in '/' Application.
--------------------------------------------------------------------------------
 
Configuration Error
 
Source Error:
 

Line 9:      <system.web>
Line 10:         <compilation debug="true" targetFramework="4.0" />
Line 11:       <sessionState cookieless="false" mode="SQLServer"  sqlConnectionString="Data Source =localhost;Initial Catalog =sample;User ID = VIGNESHJ\Admin;password=Viki;Integrated Security=true;"></sessionState>
Line 12:     </system.web>
Line 13:
Posted 9-Jan-13 5:36am
Edited 9-Jan-13 5:46am
v2
Comments
ryanb31 at 9-Jan-13 14:34pm
   
Did you run the SQL script to create the necessary tables? Also, is there more to the error?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You will need "allowCustomSqlDatabase" property to be set to "true" when specifying a custom database in your "sqlConnectionString" attribute for SessionState. Or you can remove the "initial catalog" specification from your connection string so that "ASPState" default database is used for session management.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 jyo.net 510
1 Sergey Alexandrovich Kryukov 503
2 OriginalGriff 458
3 CPallini 329
4 Afzaal Ahmad Zeeshan 300
0 OriginalGriff 1,253
1 jyo.net 994
2 DamithSL 896
3 Sergey Alexandrovich Kryukov 833
4 CPallini 720


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100