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

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

WebResponse.ContentType プロパティ

派生クラスオーバーライドされると、受信しているデータコンテンツ タイプ取得または設定します

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

例外例外
例外種類条件

NotSupportedException

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

解説解説

ContentType プロパティは、インターネット リソースからの応答MIME コンテンツ タイプ確認され場合に、その値を格納します

メモメモ

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

使用例使用例

ContentType プロパティ使用して応答コンテンツ タイプ取得する例を次に示します

' Create a 'WebRequest' 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()

' The ContentLength and ContentType received as headers in the response
 object are also exposed as properties.
   ' These provide information about the length and type of the entity
 body in the response.
Console.WriteLine(ControlChars.Cr + "Content length :{0}, Content
 Type : {1}", myWebResponse.ContentLength, myWebResponse.ContentType)
myWebResponse.Close()

         // Create a 'WebRequest' with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
 

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

// Display the content length and content type received as headers in
 the response object.
Console.WriteLine("\nContent length :{0}, Content Type : {1}", 
                             myWebResponse.ContentLength, 
                             myWebResponse.ContentType);  

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

// Create a 'WebRequest' with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com"
 );

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

// Display the content length and content type received as headers in
 the response object.
Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myWebResponse->ContentLength,
 myWebResponse->ContentType );

// Release resources of response object.
myWebResponse->Close();
// Create a 'WebRequest' with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
// Display the content length and content type received as headers 
// in the response object.
Console.WriteLine("\nContent length :{0}, Content Type : {1}", 
    System.Convert.ToString(myWebResponse.get_ContentLength()),
    System.Convert.ToString(myWebResponse.get_ContentType()));
// Release resources of response object.
myWebResponse.Close();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebResponse クラス
WebResponse メンバ
System.Net 名前空間
HttpWebResponse.ContentType プロパティ


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS