Today I was tearing my hair out trying to figure out why my Web Performance Tests were not playing back correctly. Each run stubbornly displayed, ‘System.IO.IOException Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host’. Turns out that the WebTestRequest wasn’t issued with the correct https protocol. My fix for now is to place the following in the WebTest constructor;
public WebTestCoded() { this.PreAuthenticate = true; this.Proxy = "default"; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; }