CookieHandler.Write 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
寫入 Cookie。
多載
| Write(Byte[], Boolean, DateTime) |
寫入與目前要求相關聯的 Cookie,該要求具有指定的名稱、持續性和到期時間。 |
| Write(Byte[], String, DateTime) |
寫入與目前要求相關聯的 Cookie,該要求具有指定的名稱、值和到期時間。 |
| Write(Byte[], String, DateTime, HttpContext) |
寫入與指定的要求相關聯的 Cookie,該要求具有指定的名稱、值和到期時間。 |
| Write(Byte[], String, String, String, DateTime, Boolean, Boolean, HttpContext) |
寫入與指定的要求相關聯的 Cookie,該要求具有指定的名稱、值、網域、路徑、到期時間和可見度。 |
Write(Byte[], Boolean, DateTime)
寫入與目前要求相關聯的 Cookie,該要求具有指定的名稱、持續性和到期時間。
public:
void Write(cli::array <System::Byte> ^ value, bool isPersistent, DateTime tokenExpirationTime);
public void Write (byte[] value, bool isPersistent, DateTime tokenExpirationTime);
member this.Write : byte[] * bool * DateTime -> unit
Public Sub Write (value As Byte(), isPersistent As Boolean, tokenExpirationTime As DateTime)
參數
- value
- Byte[]
Cookie 值。
- isPersistent
- Boolean
如果 Cookie 是持續性的則為 true,如果 Cookie 是工作階段專用的則為 false,也就是只在用戶端的瀏覽器關閉以前有效。
- tokenExpirationTime
- DateTime
基礎語彙基元的到期時間。
例外狀況
value 為 null 或是空的。
備註
isPersistent如果 參數為 false,則 Cookie 到期時間會設定為 DateTime.MinValue。
isPersistent如果參數為 true,則 Cookie 到期時間會設定為 屬性的值PersistentSessionLifetime,如果屬性不是 null ,則如果 PersistentSessionLifetime 屬性是 null,則到期時間會設定為 參數的值tokenExpirationTime。
Cookie 名稱、網域和路徑是由 Name、 Domain和 Path 屬性指定。 要求是由 指定 Current。 是否應該只透過 SSL 傳送 Cookie 是由 RequireSsl 屬性指定,以及是否應該從用戶端腳本隱藏 Cookie 是由 HideFromClientScript 屬性所指定。
適用於
Write(Byte[], String, DateTime)
寫入與目前要求相關聯的 Cookie,該要求具有指定的名稱、值和到期時間。
public:
void Write(cli::array <System::Byte> ^ value, System::String ^ name, DateTime expirationTime);
public void Write (byte[] value, string name, DateTime expirationTime);
member this.Write : byte[] * string * DateTime -> unit
Public Sub Write (value As Byte(), name As String, expirationTime As DateTime)
參數
- value
- Byte[]
Cookie 值。
- name
- String
Cookie 的名稱。
- expirationTime
- DateTime
Cookie 的到期時間,或會話的 DateTime.MinValue (僅限會話) Cookie。
例外狀況
value 為 null 或是空的。
name 為 null 或是空的。
備註
Cookie 網域和路徑是由 Domain 和 Path 屬性所指定。 要求是由 指定 HttpContext.Current。 要求是由 指定 Current。 是否應該只透過 SSL 傳送 Cookie 是由 RequireSsl 屬性指定,以及是否應該從用戶端腳本隱藏 Cookie 是由 HideFromClientScript 屬性所指定。
適用於
Write(Byte[], String, DateTime, HttpContext)
寫入與指定的要求相關聯的 Cookie,該要求具有指定的名稱、值和到期時間。
public:
void Write(cli::array <System::Byte> ^ value, System::String ^ name, DateTime expirationTime, System::Web::HttpContext ^ context);
public void Write (byte[] value, string name, DateTime expirationTime, System.Web.HttpContext context);
member this.Write : byte[] * string * DateTime * System.Web.HttpContext -> unit
Public Sub Write (value As Byte(), name As String, expirationTime As DateTime, context As HttpContext)
參數
- value
- Byte[]
Cookie 值。
- name
- String
Cookie 的名稱。
- expirationTime
- DateTime
Cookie 的到期時間,或會話的 DateTime.MinValue (僅限會話) Cookie。
- context
- HttpContext
要求的 HttpContext。
例外狀況
value 為 null 或是空的。
name 為 null 或是空的。
備註
Cookie 網域和路徑是由 Domain 和 Path 屬性所指定。 要求是由 指定 Current。 是否應該只透過 SSL 傳送 Cookie 是由 RequireSsl 屬性指定,以及是否應該從用戶端腳本隱藏 Cookie 是由 HideFromClientScript 屬性所指定。
適用於
Write(Byte[], String, String, String, DateTime, Boolean, Boolean, HttpContext)
寫入與指定的要求相關聯的 Cookie,該要求具有指定的名稱、值、網域、路徑、到期時間和可見度。
public:
void Write(cli::array <System::Byte> ^ value, System::String ^ name, System::String ^ path, System::String ^ domain, DateTime expirationTime, bool requiresSsl, bool hideFromClientScript, System::Web::HttpContext ^ context);
public void Write (byte[] value, string name, string path, string domain, DateTime expirationTime, bool requiresSsl, bool hideFromClientScript, System.Web.HttpContext context);
member this.Write : byte[] * string * string * string * DateTime * bool * bool * System.Web.HttpContext -> unit
Public Sub Write (value As Byte(), name As String, path As String, domain As String, expirationTime As DateTime, requiresSsl As Boolean, hideFromClientScript As Boolean, context As HttpContext)
參數
- value
- Byte[]
Cookie 值。
- name
- String
Cookie 的名稱。
- path
- String
Cookie 的路徑。
- domain
- String
Cookie 的網域。
- expirationTime
- DateTime
Cookie 的到期時間,或會話的 DateTime.MinValue (僅限會話) Cookie。
- requiresSsl
- Boolean
如果 Cookie 只能透過 SSL 連線使用,則為 true,否則為false。
- hideFromClientScript
- Boolean
如果應該對用戶端指令碼隱藏 Cookie,則為 true,否則為 false。
- context
- HttpContext
要求的 HttpContext。
例外狀況
value 為 null 或是空的。
name 為 null 或是空的。