HttpCookie.Name Eigenschaft

Definition

Dient zum Abrufen oder Festlegen des Namens eines Cookies.

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

Eigenschaftswert

Der Standardwert ist ein Nullverweis (Nothing in Visual Basic), sofern der Konstruktor nichts anderes angibt.

Beispiele

Das folgende Codebeispiel empfängt eine Cookieauflistung vom Client in der Cookie Kopfzeile und durchläuft die Sammlung, die nach einem Cookie mit dem spezifischen Namen sucht.

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
    

Gilt für:

Weitere Informationen