Share via


HttpListenerResponse.Redirect(String) Yöntem

Tanım

İstemciyi belirtilen URL'ye yeniden yönlendirmek için yanıtı yapılandırılır.

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

Parametreler

url
String

İstemcinin istenen kaynağı bulmak için kullanması gereken URL.

Örnekler

Aşağıdaki kod örneğinde bu yöntemin çağrılması gösterilmektedir.

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

Açıklamalar

Redirect yöntemi, bir istemciyi bir kaynağın yeni konumuna yeniden yönlendirmek için kullanılır. Bu yöntem yanıtın Location üst bilgisini url, StatusCode özelliğini Redirectolarak, özelliğini ise StatusDescription "Bulundu" olarak ayarlar.

Şunlara uygulanır

Ayrıca bkz.