語言

SessionIDManager.SaveSessionID(HttpContext, String, Boolean, Boolean) 方法

定義

將新建立的會話識別碼儲存在 HTTP 回應中。

public:
 virtual void SaveSessionID(System::Web::HttpContext ^ context, System::String ^ id, [Runtime::InteropServices::Out] bool % redirected, [Runtime::InteropServices::Out] bool % cookieAdded);
public void SaveSessionID(System.Web.HttpContext context, string id, out bool redirected, out bool cookieAdded);
abstract member SaveSessionID : System.Web.HttpContext * string * bool * bool -> unit
override this.SaveSessionID : System.Web.HttpContext * string * bool * bool -> unit
Public Sub SaveSessionID (context As HttpContext, id As String, ByRef redirected As Boolean, ByRef cookieAdded As Boolean)

參數

context
HttpContext

目前 HttpContext 參考用於處理 HTTP 請求的伺服器物件(例如 the Request and Response properties)。

id
String

會話標識碼。

redirected
Boolean

當此方法回傳時,包含一個布林值,即 true 回應被重新導向當前 URL 並加上會話識別碼;否則,為 false。

cookieAdded
Boolean

當此方法回傳時,包含一個布林值,即 true 若 HTTP 回應中加入了 cookie;否則, false。

實作

例外狀況

回覆已經寄出。

-或-

傳遞給此方法的會話 ID 驗證失敗。

備註

此方法並非設計用來從應用程式程式碼呼叫。

SaveSessionID該方法由物件在事件期間SessionStateModule呼叫AcquireRequestState。 此 SaveSessionID 方法會將會話識別碼儲存在網址(使用無 Cookie 會話狀態時)或非過期的會話 Cookie 中。

預設情況下,會 SessionIDManager 將唯一會話識別碼放入非過期的會話 Cookie 中,並將參數設定 cookieAdded 為 true。

對於無 cookie 會話狀態, SessionIDManager 物件會在目前 URL 中插入唯一會話識別碼,將瀏覽器導向包含會話識別碼的新網址,然後將參數設定 redirected 為 true。

適用於

另請參閱