HttpWebResponse.Close Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Yanıt akışını kapatır.
public:
override void Close();
public override void Close();
override this.Close : unit -> unit
Public Overrides Sub Close ()
Özel durumlar
.NET Core only: Bu HttpWebResponse nesnesi atılmıştır.
Örnekler
Aşağıdaki örnekte bir öğesinin nasıl kapatılmaya devam olduğu gösterilmektedir 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.
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")
Açıklamalar
Close yöntemi yanıt akışını kapatır ve kaynak bağlantısını diğer istekler tarafından yeniden kullanılmak üzere serbest bırakır.
yöntemine yapılan çağrıdan HttpWebResponse sonra nesnenin hiçbir özelliğine Close erişmemelisiniz. .NET Core'da bir ObjectDisposedException oluşturulur.
Akışı kapatmak ve bağlantıyı yeniden kullanmak üzere serbest bırakmak için veya Stream.Close yöntemini çağırmanız HttpWebResponse.Close gerekir. hem hem Stream.Closede HttpWebResponse.Close çağrısı yapmak gerekli değildir, ancak bunu yapmak bir hataya neden olmaz. Akışın kapatılamaması uygulamanızın bağlantılarının kapanmasına neden olabilir.
Note
Bu üye, uygulamanızda ağ izlemeyi etkinleştirdiğinizde izleme bilgilerini döndürür. Daha fazla bilgi için bkz. .NET Framework