The following code is not working because it downloads the actual log-in page of the URL. Yes, the text boxes for username/password. They come down as an .xls file. It's not downloading the actual file. If I go the URL myself, it DOES download the Excel file to my computer. PLEASE NOTE - When I click on the URL, it asks for my credentials.
private void btnGet_Click(object sender, EventArgs e)
{
using (WebClient client = new WebClient())
{
client.Credentials = new NetworkCredential("username", "password");
client.DownloadFile("longLink", @"C:\Report.xls");
}
}
Do I need to maybe provide a header with a session ID??