I'm attempting to parse text from a webpage that has a username and password (or download the text as a .txt file). I've been cruising around the net and stackoverflow for a few days looking for a solution. It seems like there should be a simple solution but thus far I am unable to find it. The below code seems to be the most logical and straight forward code I've found thus far. It is currently returning a Error 401 code.
private void Form1_Load(object sender, EventArgs e){
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback
(
delegate { return true; }
);
using (var client = new CookieAwareWebClient())
{
var values = new NameValueCollection
{
{ "username", "username" },
{ "password", "password" },
};
client.UploadValues("https://website/", values);
string result = client.DownloadString("https://website/licences");
lbl1.Text = result;
}
}