Can I reuse HttpWebRequest without disconnecting from the server?

You don’t reuse a request – as the name suggests, it’s one request. However, if you issue multiple requests for the same host, .NET will reuse the underlying network connection by default.

Note that you do need to dispose of the WebResponse returned by request.GetResponse – otherwise the underlying infrastructure won’t know that you’re actually done with it, and won’t be able to reuse the connection.

(As an aside, why are you using BinaryReader? Just use the stream returned by File.OpenRead directly.)

Leave a Comment