HttpContext.SetSessionStateBehavior(SessionStateBehavior) 方法

定义

设置支持 HTTP 请求所需的会话状态行为的类型。Sets the type of session state behavior that is required in order to support an HTTP request.

public:
 void SetSessionStateBehavior(System::Web::SessionState::SessionStateBehavior sessionStateBehavior);
public void SetSessionStateBehavior (System.Web.SessionState.SessionStateBehavior sessionStateBehavior);
member this.SetSessionStateBehavior : System.Web.SessionState.SessionStateBehavior -> unit
Public Sub SetSessionStateBehavior (sessionStateBehavior As SessionStateBehavior)

参数

sessionStateBehavior
SessionStateBehavior

枚举值之一,该值指定需要什么类型的会话状态行为。One of the enumeration values that specifies what type of session state behavior is required.

例外

该方法是在引发 AcquireRequestState 事件之后调用的。The method was called after the AcquireRequestState event was raised.

注解

在 ASP.NET 默认实现中,HTTP 请求处理程序通过实现接口或接口来指示它是否需要会话状态 IRequiresSessionState IReadOnlySessionStateIn the ASP.NET default implementation, an HTTP request handler indicates whether it requires session state by implementing the IRequiresSessionState interface or the IReadOnlySessionState interface. SetSessionStateBehavior方法和 SessionStateBehavior 枚举使你可以提供用于处理请求所需的会话状态支持类型的更多详细信息。The SetSessionStateBehavior method and the SessionStateBehavior enumeration let you provide more detail about what type of session state support is required in order to handle a request. 有关详细信息,请参见 SessionStateBehavior 枚举。For more information, see the SessionStateBehavior enumeration.

SetSessionStateBehavior必须在管道事件之前调用方法 AcquireRequestStateThe SetSessionStateBehavior method must be called before the AcquireRequestState pipeline event. 此事件期间或之后发生的调用将导致 InvalidOperationException 异常。Calls that occur during or after this event will cause an InvalidOperationException exception.

适用于

另请参阅