HttpListenerResponse.RedirectLocation プロパティ

定義

この応答の Location HTTP ヘッダーの値を取得または設定します。

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

プロパティ値

Location ヘッダーでクライアントに送信される絶対 URL が格納された String

例外

設定操作として指定した値が空の文字列 ("") です。

オブジェクトが閉じています。

次のコード例では、このプロパティの設定を示します。

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

注釈

ヘッダーは Location 、要求されたリソースを検索するようにクライアントに指示される URL を指定します。

Note

このプロパティを設定しても、 プロパティは自動的には StatusCode 設定されません。

適用対象

こちらもご覧ください