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 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기