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

属性值

除非构造函数另外指定,否则默认值为 null 引用(在 Visual Basic 中为 Nothing)。

示例

下面的代码示例从 标头中的客户端接收 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
    

适用于

另请参阅