WebRequest.GetRequestStream 메서드

정의

서브클래스에서 재정의될 때, 인터넷 리소스에 데이터를 쓰기 위해 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 데이터를 보내기 위한 instance 반환합니다.

메서드는 GetRequestStream 에 대한 동기 액세스를 Stream제공합니다. 비동기 액세스의 경우 및 EndGetRequestStream 메서드를 BeginGetRequestStream 사용합니다.

참고

클래스는 WebRequest 클래스입니다 abstract . 런타임에 인스턴스의 WebRequest 실제 동작은 메서드에서 반환된 하위 클래스에 WebRequest.Create 의해 결정됩니다. 기본값 및 예외에 대한 자세한 내용은 및 FileWebRequest와 같은 HttpWebRequest 하위 클래스에 대한 설명서를 참조하세요.

적용 대상

추가 정보