HttpListenerRequest.InputStream プロパティ
アセンブリ: System (system.dll 内)

要求の本体でクライアントから送信されたバイトを格納している読み取り可能な Stream オブジェクト。要求と共にデータが送信されなかった場合、このプロパティは Null を返します。

たとえば、HTTP の POST を使用してクライアントからデータが送信されている場合は、このメソッドから返されるストリームにそのデータが格納されます。
![]() |
---|
要求を終了しても、このプロパティから返されるストリームは閉じません。ストリームが不要になったら、Close メソッドを使用してストリームを閉じる必要があります。 |

このプロパティを使用して、要求と共に送信されたデータを読み込むコード例を次に示します。
public static void ShowRequestData (HttpListenerRequest request) { if (!request.HasEntityBody) { Console.WriteLine("No client data was sent with the request."); return; } System.IO.Stream body = request.InputStream; System.Text.Encoding encoding = request.ContentEncoding; System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); if (request.ContentType != null) { Console.WriteLine("Client data content type {0}", request.ContentType); } Console.WriteLine("Client data content length {0}", request.ContentLength64); Console.WriteLine("Start of client data:"); // Convert the data to a string and display it on the console. string s = reader.ReadToEnd(); Console.WriteLine(s); Console.WriteLine("End of client data:"); body.Close(); reader.Close(); // If you are finished with the request, it should be closed also. }

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


Weblioに収録されているすべての辞書からHttpListenerRequest.InputStream プロパティを検索する場合は、下記のリンクをクリックしてください。

- HttpListenerRequest.InputStream プロパティのページへのリンク