I'm trying to find a way to get the cookie for the live login service (for clubbing) that way I can login with webrequests instead of using a browser. My current issue is that when I send a httpwebrequest to any of the login pages on live it always says. You must enable cookies. No matter what I do, even enabling cookies by adding a cookie container, I can't get the webrequest to properly load the login page. Any ideas would be appreciated.
Error I'm getting:
Code I'm using to test this:
Code:
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.DocumentText = GetHttpSource("http://login.live.com/login.srf");
}
private string GetHttpSource(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = new CookieContainer();
request.UseDefaultCredentials = true;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string str = reader.ReadToEnd();
reader.Close();
responseStream.Close();
response.Close();
return str;
}