İngilizce dilinde oku

Aracılığıyla paylaş


Cookie.Value Özellik

Tanım

için Cookieöğesini Value alır veya ayarlar.

C#
public string Value { get; set; }

Özellik Değeri

Value için .Cookie

Örnekler

Aşağıdaki örnekte bir yanıtta döndürülen tanımlama bilgilerinin özellikleri gösterilir. Tam örnek için sınıf konusuna Cookie bakın.

C#
var request = (HttpWebRequest)WebRequest.Create(args[0]);
request.CookieContainer = new CookieContainer();

using (var response = (HttpWebResponse) request.GetResponse())
{
    // Print the properties of each cookie.
    foreach (Cookie cook in response.Cookies)
    {
        Console.WriteLine("Cookie:");
        Console.WriteLine($"{cook.Name} = {cook.Value}");
        Console.WriteLine($"Domain: {cook.Domain}");
        Console.WriteLine($"Path: {cook.Path}");
        Console.WriteLine($"Port: {cook.Port}");
        Console.WriteLine($"Secure: {cook.Secure}");

        Console.WriteLine($"When issued: {cook.TimeStamp}");
        Console.WriteLine($"Expires: {cook.Expires} (expired? {cook.Expired})");
        Console.WriteLine($"Don't save: {cook.Discard}");
        Console.WriteLine($"Comment: {cook.Comment}");
        Console.WriteLine($"Uri for comments: {cook.CommentUri}");
        Console.WriteLine($"Version: RFC {(cook.Version == 1 ? 2109 : 2965)}");

        // Show the string representation of the cookie.
        Console.WriteLine($"String: {cook}");
    }
}

Açıklamalar

bir ValueCookie öğesinin değeri olmamalıdır null. null Bu özelliğe bir değer atandıysa, boş bir dizeyle değiştirilir.

Noktalı virgüller ve virgüller, bu özelliğin değerinde kullanılamayabilecek ayrılmış karakterlerdir. Bu özelliğe geçersiz karakterler atanması özel durum oluşturmaz; ancak bunu Cookie yöntemiyle Add bir CookieContainer örneğe eklemeye çalıştığınızda işlem başarısız olur ve bir özel durum oluşturur.

Şunlara uygulanır

Ürün Sürümler
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Ayrıca bkz.