HttpWebResponse.Headers Özellik

Tanım

Sunucudan bu yanıtla ilişkili üst bilgileri alır.

C#
public override System.Net.WebHeaderCollection Headers { get; }

Özellik Değeri

WebHeaderCollection Yanıtla birlikte döndürülen üst bilgi bilgilerini içeren bir.

Özel durumlar

Geçerli örnek atıldı.

Örnekler

Aşağıdaki örnek, tüm yanıt üst bilgilerinin içeriğini konsola yazar.

C#
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

// Displays all the headers present in the response received from the URI.
Console.WriteLine("\r\nThe following headers were received in the response:");
// Displays each header and it's key associated with the response.
for(int i=0; i < myHttpWebResponse.Headers.Count; ++i)
    Console.WriteLine("\nHeader Name:{0}, Value :{1}",myHttpWebResponse.Headers.Keys[i],myHttpWebResponse.Headers[i]);
// Releases the resources of the response.
myHttpWebResponse.Close();

Açıklamalar

Headers özelliği, yanıtla birlikte döndürülen HTTP üst bilgi değerlerini içeren bir ad/değer çiftleri koleksiyonudur. İnternet kaynağından döndürülen ortak üst bilgi bilgileri sınıfının özellikleri HttpWebResponse olarak kullanıma sunulur. Aşağıdaki tabloda API'nin özellik olarak kullanıma sunun ortak üst bilgileri listelemektedir.

Üst bilgi Özellik
İçerik Kodlama ContentEncoding
İçerik Uzunluğu ContentLength
İçerik Türü ContentType
Last-Modified LastModified
Sunucu Server

Ş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 2.0, 2.1
UWP 10.0