Reputation: 2687
Why does creating an ASP.NET 4.5 Web Forms project in Visual Studio 2012 have the following in web.config
by default:
...
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Project.Web-20130625130806;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Project.Web-20130625130806.mdf" />
</connectionStrings>
...
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<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>
...
(My question is not about what LocalDb is or why there's a sample connection string)
It says here that InProc
means that the session state is stored in memory. Why then would you need to specify a connection string once you've declared InProc
?
Upvotes: 4
Views: 5317
Reputation: 10565
The <ConnectionStrings>
section shown above the <SessionState>
section is in NO way connected to sessionState. The ConnectionStrings section is for other purposes like when you have your own Database and you need to connect to it as well as this section only contains the details of database used for MemberShip, Profiles etc.
The <sessionState >
element has its own settings for specifying the connections string named: sqlConnectionString
as seen below:
<sessionState mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="number of minutes"
stateConnectionString="tcpip=server:port"
sqlConnectionString="sql connection string"
stateNetworkTimeout="number of seconds"/>
Now when you use mode="InProc", then there is NO need to set the sqlConnectionString setting. Even if it is set, it will not be used as the Mode is "InProc" & not " SQLServer"
Upvotes: 6