HttpWebResponse.Close HttpWebResponse.Close HttpWebResponse.Close HttpWebResponse.Close Method

정의

응답 스트림을 닫습니다.Closes the response stream.

public:
 override void Close();
public override void Close ();
override this.Close : unit -> unit
Public Overrides Sub Close ()

예외

.NET Core만 해당:HttpWebResponse 개체가 삭제된 경우.NET Core only: This HttpWebResponse object has been disposed.

예제

다음 예제에서는 종결 하는 방법을 HttpWebResponse입니다.The following example demonstrates how to close a HttpWebResponse.

// Creates an HttpWebRequest for the specified URL.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) );
// Sends the HttpWebRequest and waits for a response.
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." );
// Releases the resources of the response.
myHttpWebResponse->Close();
Console::WriteLine( "\nResponse Stream successfully closed" );
// Creates an HttpWebRequest for the specified URL. 
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); 
    // Sends the HttpWebRequest and waits for a response.
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); 
    Console.WriteLine("\nResponse Received.Trying to Close the response stream..");
    // Releases the resources of the response.
    myHttpWebResponse.Close(); 
    Console.WriteLine("\nResponse Stream successfully closed");
' Creates an HttpWebRequest for the specified URL. 
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
' Sends the HttpWebRequest and waits for a response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine("Response Received.Trying to Close the response stream..")
' Releases the resources of the response.
myHttpWebResponse.Close()
Console.WriteLine("Response Stream successfully closed")

설명

Close 메서드 응답 스트림을 닫습니다 및 다른 요청에서 다시 사용할 수 있도록 리소스에 대 한 연결을 해제 합니다.The Close method closes the response stream and releases the connection to the resource for reuse by other requests.

모든 속성에 액세스 하면 안 합니다 HttpWebResponse 호출 후 개체를 Close 메서드.You should not access any properties of the HttpWebResponse object after the call to the Close method. .NET Core에는 ObjectDisposedException throw 됩니다.On .NET Core, an ObjectDisposedException is thrown.

호출 해야 합니다 Stream.Close 또는 HttpWebResponse.Close 스트림을 닫습니다 재사용에 대 한 연결을 해제 하는 메서드.You must call either the Stream.Close or the HttpWebResponse.Close method to close the stream and release the connection for reuse. 둘 다 호출 하는 데 필요한 것 Stream.CloseHttpWebResponse.Close, 있지만 수행 하므로 오류가 발생 하지 않습니다.It is not necessary to call both Stream.Close and HttpWebResponse.Close, but doing so does not cause an error. 스트림 애플리케이션을 연결 되지 않을 수 있습니다.Failure to close the stream can cause your application to run out of connections.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다.This member outputs trace information when you enable network tracing in your application. 자세한 내용은 .NET Framework의 네트워크 추적합니다.For more information, see Network Tracing in the .NET Framework.

적용 대상