WebRequest.GetRequestStream Yöntem

Tanım

Bir alt sınıfta geçersiz kılındığında, İnternet kaynağına veri yazmak için bir Stream döndürür.

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

Döndürülenler

Stream İnternet kaynağına veri yazmak için bir.

Özel durumlar

Yöntemi alt sınıfta geçersiz kılınmadığında yöntemine erişmek için herhangi bir girişimde bulunulması.

Örnekler

Aşağıdaki örnek, bir akış almak için yöntemini kullanır GetRequestStream ve ardından akışa veri yazar.

// 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()

Açıklamalar

yöntemi, GetRequestStream İnternet kaynağına veri göndermek için bir istek başlatır ve İnternet kaynağına veri göndermek için bir Stream örnek döndürür.

GetRequestStream yöntemi, öğesine Streamzaman uyumlu erişim sağlar. Zaman uyumsuz erişim için ve EndGetRequestStream yöntemlerini kullanınBeginGetRequestStream.

Not

sınıfı WebRequest bir abstract sınıftır. Çalışma zamanında örneklerin WebRequest gerçek davranışı, yöntemi tarafından döndürülen alt sınıf tarafından WebRequest.Create belirlenir. Varsayılan değerler ve özel durumlar hakkında daha fazla bilgi için ve FileWebRequestgibi HttpWebRequest alt sınıfların belgelerine bakın.

Şunlara uygulanır

Ayrıca bkz.