WebResponse.ContentType 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 재정의될 때, 수신 중인 데이터의 콘텐츠 형식을 가져오거나 설정합니다.
public:
abstract property System::String ^ ContentType { System::String ^ get(); };
public:
virtual property System::String ^ ContentType { System::String ^ get(); void set(System::String ^ value); };
public abstract string ContentType { get; }
public virtual string ContentType { get; set; }
member this.ContentType : string
member this.ContentType : string with get, set
Public MustOverride ReadOnly Property ContentType As String
Public Overridable Property ContentType As String
속성 값
응답의 콘텐츠 형식이 들어 있는 문자열입니다.
예외
속성이 서브클래스에서 재정의되지 않았는데 속성을 가져오거나 설정하려 할 경우
예제
다음 예제에서는 사용 합니다 ContentType 속성 응답의 콘텐츠 형식을 가져옵니다.
// 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()
설명
속성은 ContentType 알려진 경우 인터넷 리소스에서 응답의 MIME 콘텐츠 형식을 포함합니다.
참고
클래스는 WebResponse 클래스입니다 abstract . 런타임에 인스턴스의 WebResponse 실제 동작은 에서 반환 WebRequest.GetResponse된 하위 클래스에 의해 결정됩니다. 기본값 및 예외에 대한 자세한 내용은 및 FileWebResponse와 같은 HttpWebResponse 하위 클래스에 대한 설명서를 참조하세요.