System.Net.WebException: The remote name could not be resolved:

It’s probably caused by a local network connectivity issue (but also a DNS error is possible). Unfortunately HResult is generic, however you can determine the exact issue catching HttpRequestException and then inspecting InnerException: if it’s a WebException then you can check the WebException.Status property, for example WebExceptionStatus.NameResolutionFailure should indicate a DNS resolution problem. It may … Read more

C# System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send

Setting the HttpWebRequest.KeepAlive to false didn’t work for me. Since I was accessing a HTTPS page I had to set the Service Point Security Protocol to Tls12. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Notice that there are other SecurityProtocolTypes: SecurityProtocolType.Ssl3 SecurityProtocolType.Tls SecurityProtocolType.Tls11 So if the Tls12 doesn’t work for you, try the three remaining options. Also notice you … Read more