WebRequest.GetRequestStream メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
派生クラスでオーバーライドされると、インターネット リソースにデータを書き込むための Stream を返します。
public:
virtual System::IO::Stream ^ GetRequestStream();
public virtual System.IO.Stream GetRequestStream ();
abstract member GetRequestStream : unit -> System.IO.Stream
override this.GetRequestStream : unit -> System.IO.Stream
Public Overridable Function GetRequestStream () As Stream
戻り値
インターネット リソースにデータを書き込む Stream。
例外
メソッドが派生クラスでオーバーライドされていないのに、そのメソッドへのアクセスが試行されました。
例
次の例では、 メソッドを GetRequestStream 使用してストリームを取得し、そのストリームのデータを書き込みます。
// Set the 'ContentType' property of the WebRequest.
myWebRequest->ContentType = "application/x-www-form-urlencoded";
// Set the 'ContentLength' property of the WebRequest.
myWebRequest->ContentLength = byteArray->Length;
Stream^ newStream = myWebRequest->GetRequestStream();
newStream->Write( byteArray, 0, byteArray->Length );
// Close the Stream object.
newStream->Close();
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
// Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType="application/x-www-form-urlencoded";
// Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength=byteArray.Length;
Stream newStream=myWebRequest.GetRequestStream();
newStream.Write(byteArray,0,byteArray.Length);
// Close the Stream object.
newStream.Close();
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse=myWebRequest.GetResponse();
' Set the 'ContentType' property of the WebRequest.
myWebRequest.ContentType = "application/x-www-form-urlencoded"
' Set the 'ContentLength' property of the WebRequest.
myWebRequest.ContentLength = byteArray.Length
Dim newStream As Stream = myWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
newStream.Close()
' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
注釈
メソッドは GetRequestStream 、インターネット リソースにデータを送信する要求を開始し、インターネット リソースにデータを Stream 送信するためのインスタンスを返します。
メソッドは GetRequestStream 、 への同期アクセスを提供します Stream。 非同期アクセスの場合は、 メソッドと EndGetRequestStream メソッドをBeginGetRequestStream使用します。
注意
クラスは WebRequest クラスです abstract
。 実行時のインスタンスの実際の WebRequest 動作は、 メソッドによって返される子孫クラスによって WebRequest.Create 決まります。 既定値と例外の詳細については、 や FileWebRequestなどのHttpWebRequest子孫クラスのドキュメントを参照してください。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示