Home:ALL Converter>Download csv file from URL return html page c#

Download csv file from URL return html page c#

Ask Time:2020-03-16T21:22:20         Author:Moran Barzilay

Json Formatter

I have a simple code to download a file from URL and it worked until few months ago.

using (WebClient client = new WebClient())
{
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    client.Encoding = Encoding.GetEncoding("Windows-1255");
    client.DownloadFile(someUrl, "Companies.csv");
}

If I enter the URL manually the file will download: CSV file URL

Why wouldn't it download via c# code?

I saw the question in C# Download file from URL but didn't seem to find my answer there.

Author:Moran Barzilay,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60706805/download-csv-file-from-url-return-html-page-c-sharp
yy