ASP.NET Session-State InProc

Why creating an ASP.NET 4.5 Web Forms project in Visual Studio 2012 defaults to web.config :

 ... <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 what LocalDb is or why there is an example connection string)

It says here that InProc means that session state is stored in memory. Why then do you need to specify the connection string after the InProc ?

+4
source share
1 answer

The <ConnectionStrings> section shown above the <SessionState> section is not connected to sessionState. The ConnectionStrings section is for other purposes, for example, when you have your own database and you need to connect to it, and this section contains only information about the database used for MemberShip, profiles, etc.

The <sessionState > element has its own settings for specifying a connection string with the name: sqlConnectionString , as shown 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 that you use mode = "InProc", there is no need to set the sqlConnectionString parameter. Even if it is installed, it will not be used because the mode is "InProc" and not "SQLServer"

+6
source

Source: https://habr.com/ru/post/1491930/


All Articles