Share via


HttpListenerResponse.RedirectLocation Proprietà

Definizione

Ottiene o imposta il valore dell'intestazione HTTP Location in questa risposta.

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

Valore della proprietà

Classe String contenente l'URL assoluto da inviare al client nell'intestazione Location.

Eccezioni

Il valore specificato per un'operazione di impostazione è una stringa vuota ("").

Questo oggetto è chiuso.

Esempio

Nell'esempio di codice seguente viene illustrata l'impostazione di questa proprietà.

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

Commenti

L'intestazione Location specifica l'URL a cui viene indirizzato il client per individuare una risorsa richiesta.

Nota

L'impostazione di questa proprietà non imposta automaticamente la StatusCode proprietà .

Si applica a

Vedi anche