HttpListenerResponse.RedirectLocation 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置此响应中 HTTP Location
标头的值。
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
属性值
String,包含要在 Location
标头中发送给客户端的绝对 URL。
例外
为设置操作指定的值为空字符串 ("")。
此对象已关闭。
示例
下面的代码示例演示如何设置此属性。
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,以便查找请求的资源。
注意
设置此属性不会自动设置 属性 StatusCode 。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈