SessionStateSection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
配置網頁應用程式的會話狀態。
public ref class SessionStateSection sealed : System::Configuration::ConfigurationSection
public sealed class SessionStateSection : System.Configuration.ConfigurationSection
type SessionStateSection = class
inherit ConfigurationSection
Public NotInheritable Class SessionStateSection
Inherits ConfigurationSection
- 繼承
範例
本節提供兩個程式碼範例。 第一個範例示範如何宣告式地指定該區段的多個屬性值,這些屬性 sessionState 也可以作為類別的 SessionStateSection 成員存取。 第二張示範如何使用這個 SessionStateSection 職業。
以下設定檔範例說明如何以宣告方式 sessionState 指定該區段的值。
<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>
以下程式碼範例示範如何使用這個 SessionStateSection 類別。
// 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");
' Get the Web application configuration.
Dim configuration As System.Configuration.Configuration = _
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/aspnetTest")
' Get the section.
Dim sessionStateSection As System.Web.Configuration.SessionStateSection = _
CType(configuration.GetSection("system.web/sessionState"), _
System.Web.Configuration.SessionStateSection)
備註
類別 SessionStateSection 指的是 Machine.config 或 Web.config 組態檔案中由 sessionState 標籤識別的元素。
當新客戶端開始與網頁應用程式互動時,會發出一個會話識別碼,並與該會話有效期間內來自同一客戶端的所有後續請求相關聯。 此 ID 用於維護客戶端會話在不同請求間的伺服器端狀態。 SessionStateSection 控制 ASP.NET 應用程式如何代表每個客戶建立並維護此關聯。
這個機制非常靈活,讓你能夠在程序外託管會話狀態資訊,並在不使用 cookie 的情況下追蹤狀態,還有其他功能。
建構函式
| 名稱 | Description |
|---|---|
| SessionStateSection() |
初始化 SessionStateSection 類別的新執行個體。 |