共用方式為


HttpCookie.Name 屬性

定義

取得或設定 Cookie 的名稱。

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

屬性值

String

預設值為 null 參考 (在 Visual Basic 為 Nothing),除非建構函式 (Constructor) 另有指定值。

範例

下列程式碼範例會從標頭中的 Cookie 用戶端接收 Cookie 集合,並迴圈查看集合中尋找具有特定名稱的 Cookie。

int loop1;
 HttpCookie MyCookie;
 HttpCookieCollection MyCookieCollection;

 MyCookieCollection = Request.Cookies;

 for (loop1 = 0; loop1 < MyCookieCollection.Count; loop1++)
 {
    MyCookie = MyCookieCollection[loop1];
    if (MyCookie.Name == "UserName")
    {
       //...
    }
 }

Dim loop1 As Integer
 Dim MyCookie As HttpCookie
 Dim MyCookieCollection As HttpCookieCollection 
 
 MyCookieCollection = Request.Cookies
 
 For loop1 = 0 TO MyCookieCollection.Count - 1
    MyCookie = MyCookieCollection(loop1)
    If MyCookie.Name = "UserName" Then
       '...
    End If
 Next loop1
    

適用於

另請參閱