WebResponse.Close 메서드

정의

서브클래스에서 재정의될 때, 응답 스트림을 닫습니다.When overridden by a descendant class, closes the response stream.

public:
 virtual void Close();
public virtual void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Overridable Sub Close ()

예외

메서드가 서브클래스에서 재정의되지 않았는데 메서드에 액세스하려 할 경우Any attempt is made to access the method, when the method is not overridden in a descendant class.

예제

다음 예제에서는 합니다 Close 닫는 메서드를는 WebResponse합니다.The following example uses the Close method to close the WebResponse.

// Create a 'WebRequest' object with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" );
// Send the 'WebRequest' and wait for response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Process the response here.
Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." );
// Release resources of response Object*.
myWebResponse->Close();
Console::WriteLine( "\nResponse Stream successfully closed" );
// Create a 'WebRequest' object with the specified url. 	
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com"); 
// Send the 'WebRequest' and wait for response.	
WebResponse myWebResponse = myWebRequest.GetResponse(); 

// Process the response here.
Console.WriteLine("\nResponse Received.Trying to Close the response stream..");
// Release resources of response object.
myWebResponse.Close();
Console.WriteLine("\nResponse Stream successfully closed");
' Create a 'WebRequest' object with the specified url 	
Dim myWebRequest As WebRequest = WebRequest.Create("www.contoso.com")
' Send the 'WebRequest' and wait for response.	
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

'  Process the response here
Console.WriteLine(ControlChars.Cr + "Response Received.Trying to Close the response stream..")
' Release resources of response object
myWebResponse.Close()
Console.WriteLine(ControlChars.Cr + "Response Stream successfully closed")

설명

합니다 Close 메서드를 사용 하는 리소스 정리를 WebResponse 를 호출 하 여 기본 스트림을 닫습니다는 Stream.Close 메서드.The Close method cleans up the resources used by a WebResponse and closes the underlying stream by calling the Stream.Close method.

참고

시스템 리소스 부족을 방지 하려면 응답을 닫아야 합니다.The response must be closed to avoid running out of system resources. 호출 하 여 응답 스트림을 닫아야 Stream.Close 또는 Close합니다.The response stream can be closed by calling Stream.Close or Close.

참고

합니다 WebResponse 클래스는 abstract 클래스입니다.The WebResponse class is an abstract class. 실제 동작 WebResponse 런타임 시 인스턴스 반환한 하위 클래스에 의해 결정 됩니다 WebRequest.GetResponse합니다.The actual behavior of WebResponse instances at run time is determined by the descendant class returned by WebRequest.GetResponse. 기본 값 및 예외에 대 한 자세한 내용은 참조 하십시오 하위 클래스에 대 한 설명서와 같은 HttpWebResponseFileWebResponse입니다.For more information about default values and exceptions, please see the documentation for the descendant classes, such as HttpWebResponse and FileWebResponse.

적용 대상

추가 정보