Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
XML
<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
Updated 9-Jan-13 5:46am
v2
Comments
ZurdoDev 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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900