Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SessionStateSection Class

Configures the session state for a Web application.

Namespace: System.Web.Configuration
Assembly: System.Web (in system.web.dll)
public sealed class SessionStateSection : ConfigurationSection
public final class SessionStateSection extends ConfigurationSection
public final class SessionStateSection extends ConfigurationSection
Not applicable.

The SessionStateSection class refers to the element in the Machine.config or Web.config configuration file identified by the sessionState tag.

When a new client begins interacting with a Web application, a session ID is issued and associated with all the subsequent requests from the same client during the time the session is valid. This ID is used to maintain server-side state associated with the client session across requests. The SessionStateSection controls how the ASP.NET application establishes and maintains this association on behalf of each client.

This mechanism is very flexible and gives you the ability to host session-state information out of process and to track state without using cookies, among other things.

This section provides two code examples. The first demonstrates how to specify values declaratively for several attributes of the sessionState section, which can also be accessed as members of the SessionStateSection class. The second demonstrates how to use the T:System.Web.Configuration.SessionStateSection class.

The following configuration file example shows how to specify values declaratively for the sessionState section.

<configuration>
  <system.web>
    <sessionState mode="InProc" 
      stateConnectionString="tcpip=127.0.0.1:42424" 
      stateNetworkTimeout="10"
      sqlConnectionString="data source=127.0.0.1;
        Integrated Security=SSPI"
      sqlCommandTimeout="30" 
      customProvider="" 
      cookieless="UseDeviceProfile" 
      cookieName="ASP.NET_SessionId" 
      timeout="20" 
      allowCustomSqlDatabase="False" 
      regenerateExpiredSessionId="False" 
      partitionResolverType="" 
      useHostingIdentity="True">
      <providers>
        <clear />
      </providers>
    </sessionState>
  </system.web>
</configuration>

The following code example demonstrates how to use the T:System.Web.Configuration.SessionStateSection class.

// Get the Web application configuration object.
System.Configuration.Configuration configuration =
  System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

// Get the section related object.
System.Web.Configuration.SessionStateSection sessionStateSection =
  (System.Web.Configuration.SessionStateSection)
  configuration.GetSection("system.web/sessionState");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.