HttpWebResponse クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ Public Class HttpWebResponse Inherits WebResponse Implements ISerializable

このクラスには、WebResponse クラスのプロパティとメソッドを HTTP 固有の方法で使用するためのサポートが含まれています。HttpWebResponse クラスは、HTTP 要求の送信および HTTP 応答の受信を行う HTTP スタンドアロン クライアント アプリケーションを構築する際に使用します。
![]() |
---|
HttpWebResponse クラスと HttpResponse クラスを混同しないでください。後者は、ASP.NET アプリケーションで使用し、そのメソッドおよびプロパティは ASP.NET の組み込み Response オブジェクトを使用して公開されます。 |
HttpWebResponse クラスのインスタンスは直接作成しないでください。代わりに、HttpWebRequest.GetResponse への呼び出しによって返されるインスタンスを使用してください。応答を閉じて、再使用のための接続を解放するために Stream.Close メソッドまたは HttpWebResponse.Close メソッドを呼び出す必要があります。Stream.Close と HttpWebResponse.Close の両方を呼び出す必要はありません。ただし、両方呼び出してもエラーは発生しません。
インターネット リソースから返される共通ヘッダー情報は、クラスのプロパティとして公開されます。全一覧については、次の表を参照してください。他のヘッダーは、Headers プロパティから、名前/値ペアとして読み取ることができます。
HttpWebResponse クラスのプロパティを通じて使用できる共通の HTTP ヘッダーを次の表に示します。
Content-Encoding | ContentEncoding |
Content-Length | ContentLength |
GetResponseStream メソッドを呼び出すことにより、インターネット リソースからの応答の内容が、Stream として返されます。

HttpWebRequest から HttpWebResponse を返す例を次に示します。
Dim HttpWReq As HttpWebRequest = _ CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest) Dim HttpWResp As HttpWebResponse = _ CType(HttpWReq.GetResponse(), HttpWebResponse) ' Insert code that uses the response object. HttpWResp.Close()
HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com"); HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse(); // Insert code that uses the response object. HttpWResp.Close();
HttpWebRequest^ HttpWReq = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://www.contoso.com" )); HttpWebResponse^ HttpWResp = dynamic_cast<HttpWebResponse^>(HttpWReq->GetResponse()); // Insert code that uses the response object. HttpWResp->Close();

System.MarshalByRefObject
System.Net.WebResponse
System.Net.HttpWebResponse


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HttpWebResponse クラスのページへのリンク