SessionStateSection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定 Web 應用程式的工作階段狀態。
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 是指標記所 sessionState
識別 Machine.config 或 Web.config 組態檔中的專案。
當新的客戶端開始與 Web 應用程式互動時,就會發出會話標識碼,並在會話有效期間與相同用戶端的所有後續要求相關聯。 此標識碼是用來維護跨要求與用戶端會話相關聯的伺服器端狀態。 控制 SessionStateSection ASP.NET 應用程式如何代表每個用戶端建立和維護此關聯。
此機制非常有彈性,可讓您裝載進程以外的會話狀態資訊,以及不使用 Cookie 來追蹤狀態等等。
建構函式
SessionStateSection() |
初始化 SessionStateSection 類別的新執行個體。 |
屬性
方法
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應