HttpListenerResponse.Redirect(String) 메서드

정의

클라이언트를 지정된 URL로 리디렉션하도록 응답을 구성합니다.

public:
 void Redirect(System::String ^ url);
public void Redirect (string url);
member this.Redirect : string -> unit
Public Sub Redirect (url As String)

매개 변수

url
String

클라이언트가 요청한 리소스를 찾는 데 사용할 URL입니다.

예제

다음 코드 예제에서는 이 메서드를 호출하는 방법을 보여 줍니다.

public static void PermanentRedirect(HttpListenerRequest request, HttpListenerResponse response)
{
    if (request.Url.OriginalString == @"http://www.contoso.com/index.html")
    {
        // Sets the location header, status code and status description.
        response.Redirect(@"http://www.contoso.com/indexServer/index.html");
    }
}
Public Shared Sub PermanentRedirect(ByVal request As HttpListenerRequest, ByVal response As HttpListenerResponse)
    If request.Url.OriginalString = "http://www.contoso.com/index.html" Then
        ' Sets the location header, status code and status description.
        response.Redirect("http://www.contoso.com/indexServer/index.html")
    End If
End Sub

설명

메서드는 Redirect 리소스의 새 위치로 클라이언트를 리디렉션하는 데 사용됩니다. 이 메서드는 응답의 Location 헤더를 url, StatusCode 속성을 로 RedirectStatusDescription 설정하고 속성을 "Found"로 설정합니다.

적용 대상

추가 정보