WebResponse.ContentLength Özellik

Tanım

Alt sınıfta geçersiz kılındığında, alınan verilerin içerik uzunluğunu alır veya ayarlar.

public:
 abstract property long ContentLength { long get(); };
public:
 virtual property long ContentLength { long get(); void set(long value); };
public abstract long ContentLength { get; }
public virtual long ContentLength { get; set; }
member this.ContentLength : int64
member this.ContentLength : int64 with get, set
Public MustOverride ReadOnly Property ContentLength As Long
Public Overridable Property ContentLength As Long

Özellik Değeri

İnternet kaynağından döndürülen bayt sayısı.

Özel durumlar

özelliği alt sınıfta geçersiz kılınmadığında özelliği almak veya ayarlamak için herhangi bir girişimde bulunulmaktadır.

Örnekler

Aşağıdaki örnek, döndürülen kaynağın ContentLength Uzunluğunu almak için özelliğini kullanır.

// Create a 'WebRequest' with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" );

// Send the 'WebRequest' and wait for response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Display the content length and content type received as headers in the response object.
Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myWebResponse->ContentLength, myWebResponse->ContentType );

// Release resources of response object.
myWebResponse->Close();

         // Create a 'WebRequest' with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com"); 

// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse(); 

// Display the content length and content type received as headers in the response object.
Console.WriteLine("\nContent length :{0}, Content Type : {1}", 
                             myWebResponse.ContentLength, 
                             myWebResponse.ContentType);  

// Release resources of response object.
myWebResponse.Close();

' Create a 'WebRequest' with the specified url. 	
Dim myWebRequest As WebRequest = WebRequest.Create("www.contoso.com")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

' The ContentLength and ContentType received as headers in the response object are also exposed as properties.
   ' These provide information about the length and type of the entity body in the response.
Console.WriteLine(ControlChars.Cr + "Content length :{0}, Content Type : {1}", myWebResponse.ContentLength, myWebResponse.ContentType)
myWebResponse.Close()

Açıklamalar

ContentLength özelliği, İnternet kaynağından gelen yanıtın uzunluğunu bayt cinsinden içerir. Üst bilgi bilgilerini içeren istek yöntemleri için, ContentLength üst bilgi bilgilerinin uzunluğunu içermez.

Not

sınıfı WebResponse bir abstract sınıftır. Çalışma zamanında örneklerin WebResponse gerçek davranışı tarafından döndürülen alt sınıf tarafından WebRequest.GetResponsebelirlenir. Varsayılan değerler ve özel durumlar hakkında daha fazla bilgi için ve gibi HttpWebResponseFileWebResponsealt sınıfların belgelerine bakın.

Şunlara uygulanır

Ayrıca bkz.