Hi there,
I am very stuck and have tried everything on this one!
I am trying to get to an https website and cannot work out how to
logon. When I log on manually, I have to enter username and password in
a dialog box.
I am trying to use Basic Authorisation to get in and everything I try
returns a 401 unauthoriased error. I am sure this should be simple :-(
Thanks,
Phil
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://www.website.co.uk");
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "GET";
string base64EncodedAuthorizationString = "user" + ":" + "pass";
byte[] binaryData = new Byte[base64EncodedAuthorizationString.Length];
binaryData = Encoding.ASCII.GetBytes(base64EncodedAuthorization String);
base64EncodedAuthorizationString =
Convert.ToBase64String(binaryData);
base64EncodedAuthorizationString = "Basic " +
base64EncodedAuthorizationString;
req.Headers.Add("Authorization", base64EncodedAuthorizationString);
HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();