HttpListenerRequest.AcceptTypes 속성

정의

클라이언트에서 받아들일 수 있는 MIME 형식을 가져옵니다.

public:
 property cli::array <System::String ^> ^ AcceptTypes { cli::array <System::String ^> ^ get(); };
public string[]? AcceptTypes { get; }
public string[] AcceptTypes { get; }
member this.AcceptTypes : string[]
Public ReadOnly Property AcceptTypes As String()

속성 값

String[]

요청의 Accept 헤더에 지정된 형식 이름이 들어 있는 String 배열이거나, 클라이언트 요청에 null 헤더가 포함되어 있지 않은 경우 Accept입니다.

예제

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

public static void ShowRequestProperties1 (HttpListenerRequest request)
{
    // Display the MIME types that can be used in the response.
    string[] types = request.AcceptTypes;
    if (types != null)
    {
        Console.WriteLine("Acceptable MIME types:");
        foreach (string s in types)
        {
            Console.WriteLine(s);
        }
    }
    // Display the language preferences for the response.
    types = request.UserLanguages;
    if (types != null)
    {
        Console.WriteLine("Acceptable natural languages:");
        foreach (string l in types)
        {
            Console.WriteLine(l);
        }
    }

    // Display the URL used by the client.
    Console.WriteLine("URL: {0}", request.Url.OriginalString);
    Console.WriteLine("Raw URL: {0}", request.RawUrl);
    Console.WriteLine("Query: {0}", request.QueryString);

    // Display the referring URI.
    Console.WriteLine("Referred by: {0}", request.UrlReferrer);

    //Display the HTTP method.
    Console.WriteLine("HTTP Method: {0}", request.HttpMethod);
    //Display the host information specified by the client;
    Console.WriteLine("Host name: {0}", request.UserHostName);
    Console.WriteLine("Host address: {0}", request.UserHostAddress);
    Console.WriteLine("User agent: {0}", request.UserAgent);
}
Public Shared Sub ShowRequestProperties1(ByVal request As HttpListenerRequest)
    ' Display the MIME types that can be used in the response.
    Dim types As String() = request.AcceptTypes

    If types IsNot Nothing Then
        Console.WriteLine("Acceptable MIME types:")

        For Each s As String In types
            Console.WriteLine(s)
        Next
    End If

    ' Display the language preferences for the response.
    types = request.UserLanguages

    If types IsNot Nothing Then
        Console.WriteLine("Acceptable natural languages:")

        For Each l As String In types
            Console.WriteLine(l)
        Next
    End If

    ' Display the URL used by the client.
    Console.WriteLine("URL: {0}", request.Url.OriginalString)
    Console.WriteLine("Raw URL: {0}", request.RawUrl)
    Console.WriteLine("Query: {0}", request.QueryString)

    ' Display the referring URI.
    Console.WriteLine("Referred by: {0}", request.UrlReferrer)

    ' Display the HTTP method.
    Console.WriteLine("HTTP Method: {0}", request.HttpMethod)

    ' Display the host information specified by the client.
    Console.WriteLine("Host name: {0}", request.UserHostName)
    Console.WriteLine("Host address: {0}", request.UserHostAddress)
    Console.WriteLine("User agent: {0}", request.UserAgent)
End Sub

설명

헤더는 Accept 클라이언트가 응답에서 수락하고 처리할 준비가 된 MIME 형식을 나타내는 공백으로 구분된 MIME(Multipurpose Internet Mail Extensions) 형식 이름(예 image/jpeg: )의 문자열입니다. 항목은 */* 클라이언트가 모든 MIME 형식을 허용한다는 것을 나타냅니다. 헤더에 대한 자세한 설명 Accept 은 에서 https://www.rfc-editor.org제공되는 RFC 2616을 참조하세요.

요청 헤더의 전체 목록은 열거형을 HttpRequestHeader 참조하세요.

적용 대상

추가 정보