이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
번역
원본
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

HttpListenerRequest.ContentType 속성

요청에 포함된 본문 데이터의 MIME 형식을 가져옵니다.

네임스페이스:  System.Net
어셈블리:  System(System.dll)
public string ContentType { get; }

속성 값

형식: System.String
요청의 Content-Type 헤더 텍스트가 들어 있는 String입니다.

클라이언트에서는 요청에 본문 데이터를 포함시킬 경우 Content-Type 헤더에 본문 데이터의 MIME(Multipurpose Internet Mail Extensions) 형식을 선언합니다. 예를 들어 POST 메서드를 사용하여 Web form에서 반환된 데이터의 기본 MIME 형식은 application/x-www-form-urlencoded입니다.

자세한 요청 헤더 목록은 HttpRequestHeader 열거형과 http://www.rfc-editor.org의 RFC 2616을 참조하십시오.

요청에 Content-Type 헤더가 없으면 ContentType이 null입니다.

다음 코드 예제에서는 이 속성을 사용하는 방법을 보여 줍니다.


public static void ShowRequestData (HttpListenerRequest request)
{
    if (!request.HasEntityBody)
    {
        Console.WriteLine("No client data was sent with the request.");
        return;
    }
    System.IO.Stream body = request.InputStream;
    System.Text.Encoding encoding = request.ContentEncoding;
    System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
    if (request.ContentType != null)
    {
        Console.WriteLine("Client data content type {0}", request.ContentType);
    }
    Console.WriteLine("Client data content length {0}", request.ContentLength64);

    Console.WriteLine("Start of client data:");
    // Convert the data to a string and display it on the console.
    string s = reader.ReadToEnd();
    Console.WriteLine(s);
    Console.WriteLine("End of client data:");
    body.Close();
    reader.Close();
    // If you are finished with the request, it should be closed also.
}


.NET Framework

4.5, 4, 3.5, 3.0, 2.0에서 지원

.NET Framework Client Profile

4, 3.5 SP1에서 지원

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)

.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
© 2013 Microsoft. All rights reserved.