Re: Bug in HttpWebRequest/Response Dispose() implementation?



I am not in the office right now, but I guess the original code looked like
this:

HttpWebRequest request = PrepareRequest(...);
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
... do something with response
}

HttpWebRequest is not disposable, so we applied "using" pattern to
HttpWebResponse object only.

While searching for the source of the problem, I found couple of documents:

http://dturini.blogspot.com/2004/06/on-past-few-days-im-dealing-with-some.html

http://support.microsoft.com/?kbid=831138

Looks like there .NET 1.1 had a problem with release of unmanaged resources
allocated by HttpResponse. Does .NET 2.0 has the same problem?

Vagif


"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1f1628b79eefde3798d2c3@xxxxxxxxxxxxxxxxxxxxxxx
Vagif Abilov <vagif@xxxxxxxxx> wrote:
Hello,

We have a simple piece of code that exchanges data using HTTP
request/reponse. It uses "using" statement to guarantee that the
communication channel is properly closed on completion. However, if the
code
is executed multiple times, the first execution attempt works fine, but
the
second attempt times out.

<snip>

Why using Dispose method does not do the same? Isn't it the purpose of
IDisposable interface?

Yes. Could you show us the code that doesn't work, preferrably as a
short but complete program?

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


.



Relevant Pages

  • Re: POST info to website from web service
    ... HttpWebRequest request = ... HttpWebResponse response = request.GetResponse; ... // we will read data via the response stream ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Bug in HttpWebRequest/Response Dispose() implementation?
    ... Vagif Abilov wrote: ... HttpWebRequest request = PrepareRequest; ... do something with response ... HttpWebRequest is not disposable, so we applied "using" pattern to ...
    (microsoft.public.dotnet.framework.clr)
  • RE: OWSSVR.DLL 401 Unauthorized
    ... HttpWebRequest request = ... response = request.GetResponse; ... Stream resStream = response.GetResponseStream; ...
    (microsoft.public.sharepoint.portalserver.development)
  • RE: HTTPS WebRequest and WebResponse
    ... > // Creates an HttpWebRequest for the specified URL. ... > // Displays all the headers present in the response received from the URI. ... > // Obtain a 'Stream' object associated with the response object. ... > StreamReader readStream = new StreamReader(ReceiveStream, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Capturing XML pages from Server
    ... Thanks for your response and glad that it's of assistance. ... Microsoft Online Support ... WE can use the HttpWebRequest to send get/post ... |> Get Secure! ...
    (microsoft.public.dotnet.framework.aspnet)

Loading