Guest User

Guest User

  • Tech Writer
  • 6
  • 18.4k

C# WebClient throws error while downloading a URL String

May 18 2017 9:41 AM
Hi,
A URL was working fine for last many months but suddenly stops working in C# but the same URL is working in Excel VBA using  MSXML2.XMLHTTP60 request.
 
I tried Webclient and HTMLAgility but both fails in dowloading string from a web URL
 
private void webClienttry()
{
WebClient webClient = new WebClient();
string result = webClient.DownloadString("https://www.komplett.no/category/10448/tv?subcategory=11157_TV-er&hits=200");
Console.WriteLine(result);
}
 
Error:
System.Net.WebException: 'The underlying connection was closed: An unexpected error occurred on a send.' 
IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
 Can anyone help me finding the cause of error.
 
Thanks
 
Regards/Sachin 

Answers (5)