HttpListenerResponse.Redirect(String) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した URL にクライアントをリダイレクトするように応答を構成します。
public:
void Redirect(System::String ^ url);
public void Redirect (string url);
member this.Redirect : string -> unit
Public Sub Redirect (url As String)
パラメーター
- url
- String
クライアントが要求されたリソースの検索に使用する URL。
例
次のコード例では、このメソッドの呼び出しを示します。
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
注釈
メソッドは Redirect 、クライアントをリソースの新しい場所にリダイレクトするために使用されます。 このメソッドは、応答の Location
ヘッダーを に設定し url
、プロパティを StatusCode に Redirect、プロパティを StatusDescription "Found" に設定します。
適用対象
こちらもご覧ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示