HttpHeaders.Add メソッド

定義

新しいヘッダーと値を HttpHeaders コレクションに挿入します。

オーバーロード

Add(String, IEnumerable<String>)

HttpHeaders コレクションに指定のヘッダーと値を追加します。

Add(String, String)

HttpHeaders コレクションに指定のヘッダーと値を追加します。

Add(String, IEnumerable<String>)

HttpHeaders コレクションに指定のヘッダーと値を追加します。

public:
 void Add(System::String ^ name, System::Collections::Generic::IEnumerable<System::String ^> ^ values);
public void Add (string name, System.Collections.Generic.IEnumerable<string> values);
public void Add (string name, System.Collections.Generic.IEnumerable<string?> values);
member this.Add : string * seq<string> -> unit
Public Sub Add (name As String, values As IEnumerable(Of String))

パラメーター

name
String

コレクションに追加するヘッダー。

values
IEnumerable<String>

コレクションに追加するヘッダー値のリスト。

例外

この名前を null または空にすることはできません。

この値を null または空にすることはできません。

誤って使用されたヘッダー名。 要求ヘッダーが HttpRequestMessage オブジェクトで、応答ヘッダーが HttpResponseMessage オブジェクトで、コンテンツ ヘッダーが HttpContent オブジェクトで使用されていることを確認してください。

ヘッダー名の形式が無効です。

  • または -

ヘッダーの値の改行文字の後には空白文字が必要です。

注釈

ヘッダー values が解析され、検証されます。

指定したヘッダーが存在しない場合、メソッドは Add ヘッダー名と値のペアの一覧に新しいヘッダーを挿入します。

指定したヘッダーが既に存在する場合は、 values ヘッダーに関連付けられている値のコンマ区切りのリストに追加されます。

適用対象

Add(String, String)

HttpHeaders コレクションに指定のヘッダーと値を追加します。

public:
 void Add(System::String ^ name, System::String ^ value);
public void Add (string name, string value);
public void Add (string name, string? value);
member this.Add : string * string -> unit
Public Sub Add (name As String, value As String)

パラメーター

name
String

コレクションに追加するヘッダー。

value
String

ヘッダーの内容。

例外

この名前を null または空にすることはできません。

誤って使用されたヘッダー名。 要求ヘッダーが HttpRequestMessage オブジェクトで、応答ヘッダーが HttpResponseMessage オブジェクトで、コンテンツ ヘッダーが HttpContent オブジェクトで使用されていることを確認してください。

ヘッダー名の形式が無効です。

  • または -

ヘッダーの値の改行文字の後には空白文字が必要です。

注釈

ヘッダー value が解析され、検証されます。

指定したヘッダーが存在しない場合、メソッドは Add ヘッダー名と値のペアの一覧に新しいヘッダーを挿入します。

指定したヘッダーが既に存在する場合は、 value ヘッダーに関連付けられている値のコンマ区切りのリストに追加されます。

適用対象