HttpListenerResponse.RedirectLocation Vlastnost

Definice

Získá nebo nastaví hodnotu hlavičky HTTP Location v této odpovědi.

public:
 property System::String ^ RedirectLocation { System::String ^ get(); void set(System::String ^ value); };
public string? RedirectLocation { get; set; }
public string RedirectLocation { get; set; }
member this.RedirectLocation : string with get, set
Public Property RedirectLocation As String

Hodnota vlastnosti

A String , který obsahuje absolutní adresu URL, která má být odeslána klientovi v hlavičce Location .

Výjimky

Hodnota zadaná pro operaci set je prázdný řetězec ("").

Tento objekt je zavřený.

Příklady

Následující příklad kódu ukazuje nastavení této vlastnosti.

public static void TemporaryRedirect(HttpListenerRequest request, HttpListenerResponse response)
{
    if (request.Url.OriginalString == @"http://www.contoso.com/index.html")
    {
        response.RedirectLocation = @"http://www.contoso.com/indexServer/index.html";
    }
}
Public Shared Sub TemporaryRedirect(ByVal request As HttpListenerRequest, ByVal response As HttpListenerResponse)
    If request.Url.OriginalString = "http://www.contoso.com/index.html" Then
        response.RedirectLocation = "http://www.contoso.com/indexServer/index.html"
    End If
End Sub

Poznámky

Hlavička Location určuje adresu URL, na kterou je klient přesměrován, aby vyhledal požadovaný prostředek.

Poznámka

Nastavením této vlastnosti se vlastnost nenastaví StatusCode automaticky.

Platí pro

Viz také