इसके माध्यम से साझा किया गया


HttpResponseHeaderCollection.Location Property

Definition

Gets or sets the Uri that represents the value or a Location HTTP header on an HTTP response.

public:
 property Uri ^ Location { Uri ^ get(); void set(Uri ^ value); };
Uri Location();

void Location(Uri value);
public System.Uri Location { get; set; }
var uri = httpResponseHeaderCollection.location;
httpResponseHeaderCollection.location = uri;
Public Property Location As Uri

Property Value

The object that represents the value of a Location HTTP header on an HTTP response. A null value means that the header is absent.

Remarks

The following sample code shows a method to set the Location header on an HttpResponseMessage object using the Location property on the HttpResponseHeaderCollection object.

public void DemonstrateHeaderResponseLocation() {
    var response = new HttpResponseMessage();

    // Set the header with a strong type.
    response.Headers.Location = new Uri("http://example.com/");

    // Get the strong type out
    System.Diagnostics.Debug.WriteLine("Location absolute uri: {0}", response.Headers.Location.AbsoluteUri);

    // The ToString() is useful for diagnostics, too.
    System.Diagnostics.Debug.WriteLine("The Location ToString() results: {0}", response.Headers.Location.ToString());
}

Applies to

See also