WebRequest.ContentLength 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
서브클래스에서 재정의될 때, 전송 중인 요청 데이터의 콘텐츠 길이를 가져오거나 설정합니다.
public:
virtual property long ContentLength { long get(); void set(long value); };
public virtual long ContentLength { get; set; }
member this.ContentLength : int64 with get, set
Public Overridable Property ContentLength As Long
속성 값
전송 중인 요청 데이터의 바이트 수입니다.
예외
속성이 서브클래스에서 재정의되지 않았는데 속성을 가져오거나 설정하려 할 경우
예제
다음은 나가는 바이트 버퍼의 바이트 양으로 속성을 설정하는 ContentLength 예제입니다.
// Set the 'ContentType' property of the WebRequest.
myWebRequest->ContentType = "application/x-www-form-urlencoded";
// Set the 'ContentLength' property of the WebRequest.
myWebRequest->ContentLength = byteArray->Length;
Stream^ newStream = myWebRequest->GetRequestStream();
newStream->Write( byteArray, 0, byteArray->Length );
// Close the Stream object.
newStream->Close();
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
// Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType="application/x-www-form-urlencoded";
// Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength=byteArray.Length;
Stream newStream=myWebRequest.GetRequestStream();
newStream.Write(byteArray,0,byteArray.Length);
// Close the Stream object.
newStream.Close();
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse=myWebRequest.GetResponse();
' Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType = "application/x-www-form-urlencoded"
' Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength = byteArray.Length
Dim newStream As Stream = myWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
newStream.Close()
' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
설명
이 속성에는 ContentLength 인스턴스가 인터넷 리소스 WebRequest 로 보낸 데이터의 바이트 수가 포함됩니다.
참고
WebRequest 클래스는 클래스입니다abstract. 런타임에 인스턴스의 WebRequest 실제 동작은 메서드에서 반환된 하위 클래스에 의해 WebRequest.Create 결정됩니다. 기본값 및 예외에 대한 자세한 내용은 하위 클래스(예 HttpWebRequest : 및 FileWebRequest)에 대한 설명서를 참조하세요.