HttpListenerRequest.UrlReferrer 속성

정의

클라이언트를 서버에 연결시킨 리소스의 URI(Uniform Resource Identifier)를 가져옵니다.

public:
 property Uri ^ UrlReferrer { Uri ^ get(); };
public Uri? UrlReferrer { get; }
public Uri UrlReferrer { get; }
member this.UrlReferrer : Uri
Public ReadOnly Property UrlReferrer As Uri

속성 값

Uri

요청의 Uri 헤더 텍스트가 들어 있는 Referer 개체이거나, 헤더가 요청에 포함되지 않은 경우 null입니다.

예제

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

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

설명

클라이언트가 요청된 URI에 대한 하이퍼링크를 따른 경우 해당 요청에 하이퍼링크가 포함된 리소스의 URI를 식별하는 헤더가 포함될 Referrer 수 있습니다.

클라이언트는 헤더를 표시 Referer 하지 않도록 위조하거나 선택할 수 있습니다. 따라서 속성은 웹 트래픽의 UrlReferrer 기본 추세를 식별하는 데 유용할 수 있지만 데이터에 대한 액세스를 제어하는 권한 부여 체계의 일부로 사용하면 안 됩니다.

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

요청에 UrlReferrer 헤더가 없거나 Referrer 헤더가 요청에 있지만 유효한 Uri로 구문 분석되지 않는 경우 Referrer 은 null입니다.

적용 대상

추가 정보