Share via


HttpResponseHeaderCollection.Location プロパティ

定義

HTTP 応答の値または Location HTTP ヘッダーを表す Uri を取得または設定します。

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 応答の Location 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());
}

適用対象

こちらもご覧ください