WebResponse.Headers プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebResponse.Headers プロパティの意味・解説 

WebResponse.Headers プロパティ

派生クラスオーバーライドされると、要求関連付けられたヘッダーの名前/値ペアコレクション取得します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Public Overridable ReadOnly
 Property Headers As WebHeaderCollection
Dim instance As WebResponse
Dim value As WebHeaderCollection

value = instance.Headers
public virtual WebHeaderCollection Headers { get;
 }
public:
virtual property WebHeaderCollection^ Headers {
    WebHeaderCollection^ get ();
}
/** @property */
public WebHeaderCollection get_Headers ()
public function get Headers
 () : WebHeaderCollection

プロパティ
応答関連付けられたヘッダー値を格納する WebHeaderCollection クラスインスタンス

例外例外
例外種類条件

NotSupportedException

プロパティ派生クラスオーバーライドされていないのに、そのプロパティ取得または設定試行されました。

解説解説

Headers プロパティは、要求返されるヘッダーの名前/値ペア格納します

メモメモ

WebResponse クラスは、abstract クラスです。実行時WebResponse インスタンス実際動作は、WebRequest.GetResponse で返される派生クラスによって決まります既定値および例外詳細については、HttpWebResponse や FileWebResponse などの派生クラス説明参照してください

使用例使用例

WebResponse返されるヘッダーの名前/値ペアをすべて表示する例を次に示します

    ' Create a 'WebRequest' object with the specified url     
    Dim myWebRequest As WebRequest = WebRequest.Create("www.contoso.com")
    
    ' Send the 'WebRequest' and wait for response.
    Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
    
    ' Display all the Headers present in the response received from
 the URl.
    Console.WriteLine(ControlChars.Cr + "The following headers
 were received in the response")
    
    ' Headers property is a 'WebHeaderCollection'. Use it's properties
 to traverse the collection and display each header
    Dim i As Integer
    
    While i < myWebResponse.Headers.Count
        Console.WriteLine(ControlChars.Cr + "Header Name:{0},
 Header value :{1}", myWebResponse.Headers.Keys(i), myWebResponse.Headers(i))
i = i + 1
    End While

    ' Release resources of response object.
    myWebResponse.Close()
    
    // Create a 'WebRequest' object with the specified url.     
   WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
 

   // Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse(); 

   // Display all the Headers present in the response received from
 the URl.
   Console.WriteLine("\nThe following headers were received in
 the response");

// Display each header and it's key , associated with the response object.
   for(int i=0; i < myWebResponse.Headers.Count;
 ++i)  
      Console.WriteLine("\nHeader Name:{0}, Header value :{1}",myWebResponse.Headers.Keys[i],myWebResponse.Headers[i]);
 

   // Release resources of response object.
   myWebResponse.Close(); 
   
// Create a 'WebRequest' object with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com"
 );

// Send the 'WebRequest' and wait for response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Display all the Headers present in the response received from the
 URl.
Console::WriteLine( "\nThe following headers were received in
 the response" );

// Display each header and its key , associated with the response object.
for ( int i = 0; i < myWebResponse->Headers->Count;
 ++i )
   Console::WriteLine( "\nHeader Name: {0}, Header value : {1}", myWebResponse->Headers->Keys[
 i ], myWebResponse->Headers[ i ] );

// Release resources of response object.
myWebResponse->Close();

// Create a 'WebRequest' object with the specified url.     
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
// Display all the Headers present in the response received from 
// the URl.
Console.WriteLine("\nThe following headers were received in
 the " 
    + "response");
// Display each header and it's key , associated with the response 
// object.
for (int i = 0; i < myWebResponse.get_Headers().get_Count();
 ++i) {
    Console.WriteLine("\nHeader Name:{0}, Header value :{1}",
        myWebResponse.get_Headers().get_Keys().get_Item(i), 
        myWebResponse.get_Headers().get_Item(i));
}
// Release resources of response object.
myWebResponse.Close();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebResponse クラス
WebResponse メンバ
System.Net 名前空間
WebHeaderCollection クラス
HttpWebResponse.Headers プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebResponse.Headers プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebResponse.Headers プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebResponse.Headers プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

WebResponse.Headers プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebResponse.Headers プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS