Willy
Willy

Reputation: 10648

Changing ASP.NET InProc session state mode into State Server or SQL Server State

First, I am new to Web app programming. I come from Desktop apps (WinForms & WPF). Recently I have been assigned a project that was made in the past by ohter people. This project is done in ASP.NET MVC and it uses an InProc session state mode.

Now, I want to build a web gardening, that is, use multiple worker process for the application pool. I have googled and I have discovered that InProc session does not work with web gardening because each worker process within app pool uses its own session state. So I am planning to switch it into another session state mode such as State Server or SQL Server.

Now I have a doubt. Apart from changing session state mode in Web.config:

<configuration>  
  <system.web>      
    <sessionState mode="InProc" timeout="25"></sessionState>  
  </system.web>  
</configuration>

... Do I need to do some extra work? for example reprogramming the ASP.NET MVC app, configuration or some other things in order it to work?

Below I share some interesting links:

Upvotes: 0

Views: 2537

Answers (1)

Javid Gahramanov
Javid Gahramanov

Reputation: 112

For web farms you should keep your session either in StateServer or Sql Server. To do so you need to add following configuration

     <connectionStrings>
           <add name="ConnectionString1" 
           connectionString="Data Source=YourServer;Initial 
           Catalog=SessionDatabase;Integrated Security=True"
           providerName="System.Data.SqlClient" />
    </connectionStrings>



<!--Change your <sessionState mode="InProc" timeout="25"></sessionState>  to this.-->

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

Upvotes: 0

Related Questions