HttpListenerResponse.RedirectLocation HttpListenerResponse.RedirectLocation HttpListenerResponse.RedirectLocation HttpListenerResponse.RedirectLocation Property

Definition

Gets or sets the value of the HTTP Location header in this response.

public:
 property System::String ^ RedirectLocation { System::String ^ get(); void set(System::String ^ value); };
public string RedirectLocation { get; set; }
member this.RedirectLocation : string with get, set
Public Property RedirectLocation As String

Property Value

A String that contains the absolute URL to be sent to the client in the Location header.

Exceptions

The value specified for a set operation is an empty string ("").

Examples

The following code example demonstrates setting this property.

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

Remarks

The Location header specifies the URL to which the client is directed to locate a requested resource.

Note

Setting this property does not automatically set the StatusCode property.

Applies to

See also