Reproduce "A connection that was expected to be kept alive was closed by the server."
<p>We're using WebClient, .NET 3.5sp1 in a winforms application. For some users this results
in an Exception with the message:</p>

<p>"The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."</p>

<p>Searching a bit around the web suggests a "fix" to just disable http keepalive, which we're not really interested in doing, some suggests it might be a bug in the .NET libraries, etc.</p>

<p>The error message suggests it's a keepaliv'ed http connection that somehow got closed by the server(or a proxy) without the underlyings of WebClient detecting it properly.</p>

<p>We're thinking of catching this specific case, and simply try the request again. However we cannot reproduce this exception. So.</p>

<ol>
<li><p>How can we properly catch the case that yields the above error message. </p>

<p>catch(WebException ex) {
    if (ex.Message == "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server") { ... }</p>

<p>smells.. bad.</p></li>
<li><p>Any tips on how we can reproduce the above exception ?</p></li>
</ol>
