Share via


HttpListenerResponse.RedirectLocation Properti

Definisi

Mendapatkan atau mengatur nilai header HTTP Location dalam respons ini.

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

Nilai Properti

String yang berisi URL absolut yang akan dikirim ke klien di Location header .

Pengecualian

Nilai yang ditentukan untuk operasi set adalah string kosong ("").

Objek ini ditutup.

Contoh

Contoh kode berikut menunjukkan pengaturan properti ini.

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

Keterangan

Header Location menentukan URL tempat klien diarahkan untuk menemukan sumber daya yang diminta.

Catatan

Mengatur properti ini tidak secara otomatis menyetel StatusCode properti .

Berlaku untuk

Lihat juga