Bagikan melalui


HttpResponseHeaderCollection.Location Properti

Definisi

Mendapatkan atau mengatur Uri yang mewakili nilai atau header HTTP Lokasi pada respons HTTP.

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

Nilai Properti

Objek yang mewakili nilai header HTTP Lokasi pada respons HTTP. Nilai null berarti header tidak ada.

Keterangan

Kode sampel berikut menunjukkan metode untuk mengatur header Lokasi pada objek HttpResponseMessage menggunakan properti Lokasi pada objek HttpResponseHeaderCollection .

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());
}

Berlaku untuk

Lihat juga