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 引用 Machine.config 或 Web.config 标记标识的配置文件中的 sessionState
元素。
当新客户端开始与 Web 应用程序交互时,将发出会话 ID,并在会话有效期间与来自同一客户端的所有后续请求相关联。 此 ID 用于跨请求维护与客户端会话关联的服务器端状态。 控制 SessionStateSection ASP.NET 应用程序如何代表每个客户端建立和维护此关联。
此机制非常灵活,使你能够在进程外托管会话状态信息,并在不使用 Cookie 的情况下跟踪状态。
构造函数
SessionStateSection() |
初始化 SessionStateSection 类的新实例。 |
属性
方法
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈