次の方法で共有


HttpWebRequest.Accept プロパティ

Accept HTTP ヘッダーの値を取得または設定します。

Public Property Accept As String
[C#]
public string Accept {get; set;}
[C++]
public: __property String* get_Accept();public: __property void set_Accept(String*);
[JScript]
public function get Accept() : String;public function set Accept(String);

プロパティ値

Accept HTTP ヘッダーの値。既定値は null 参照 (Visual Basic では Nothing) です。

解説

Accept HTTP ヘッダーをクリアするには、 Accept プロパティを null 参照 (Visual Basic では Nothing) に設定します。

使用例

[Visual Basic, C#, C++] Accept プロパティを設定する例を次に示します。

 
' Create a 'HttpWebRequest' object.
Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create(myUri)
' Set the 'Accept' property to accept an image of any type.
myHttpWebRequest.Accept = "image/*"
' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

[C#] 
// Create a 'HttpWebRequest' object.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(myUri);
// Set the 'Accept' property to accept an image of any type.
myHttpWebRequest.Accept="image/*";
// The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();

[C++] 
// Create a 'HttpWebRequest' object.
HttpWebRequest* myHttpWebRequest = 
   dynamic_cast<HttpWebRequest*>(WebRequest::Create(myUri));
// Set the 'Accept' property to accept an image of any type.
myHttpWebRequest->Accept=S"image/*";
// The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
HttpWebResponse* myHttpWebResponse =
   dynamic_cast<HttpWebResponse*>(myHttpWebRequest->GetResponse());

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

HttpWebRequest クラス | HttpWebRequest メンバ | System.Net 名前空間