views:

208

answers:

1

I would like to better understand how .Net http connection reuse works.

  1. When I use HttpWebRequest to send something to some server twice from the same appdomain, is the connection (optionally) reused? So the server would see both requests as coming from the same connection even though in my application they are different logical requests.

  2. If yes, can this behavior be turned off?

  3. What about connections that use authentication/ssl - are they also also reused? If I supply different credentials/policy for each request this can be a security hole.

+1  A: 

The connection re-use is using HTTP Keep-alive which is a feature of HTTP/1.1. By using HTTP Keep-alive one TCP connection is used for handling multiple HTTP requests sequentially so one saves time to open a new TCP connection for every request. Each HTTP request itself is then again independent so authentification and similar won't be re-used automatically.

johannes