HttpResponseHeaderCollection.Location 屬性

定義

取得或設定 URI ,表示 HTTP 回應上的值或 位置 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

屬性值

物件,表示 HTTP 回應上 位置 HTTP 標頭的值。 Null值表示標頭不存在。

備註

下列範例程式碼示範使用HttpResponseHeaderCollection物件上的 Location 屬性,在HttpResponseMessage物件上設定Location標頭的方法。

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

適用於

另請參閱