download file from https with credentials doesn't contain data

Stacy Bell 41 Reputation points
2021-12-29T23:41:35.75+00:00

This downloads an online file but the file has the website's html code instead of data. How do you get the file to have data instead of html code?

        var url = string.Format(@"https://www.test.com/Monthly%20Report");
        WebClient webClient = new WebClient();
        webClient.Credentials = new NetworkCredential("userName", "Password123");
        webClient.Headers.Add("cookie", "");
        webClient.DownloadFile(url, @"C:\Users\me\Downloads\Monthly Report.csv");
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.