Export (0) Print
Expand All

HttpListenerResponse.RedirectLocation Property

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

Namespace: System.Net
Assembly: System (in system.dll)

public string RedirectLocation { get; set; }
/** @property */
public String get_RedirectLocation ()

/** @property */
public void set_RedirectLocation (String value)

public function get RedirectLocation () : String

public function set RedirectLocation (value : String)

Not applicable.

Property Value

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

Exception typeCondition

ArgumentException

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

ObjectDisposedException

This object is closed.

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

NoteNote:

Setting this property does not automatically set the StatusCode property.

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 static void TemporaryRedirect(HttpListenerRequest request, 
    HttpListenerResponse response)
{
    if (request.get_Url().get_OriginalString().Equals(
        "http://www.contoso.com/index.html")) {
        response.set_RedirectLocation(
            "http://www.contoso.com/indexServer/index.html");
    }
} //TemporaryRedirect

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft