|
-
August 7th, 2009, 12:05 AM
#1
[Help] "Enabling" cookies in a webrequest
I am trying to wright a class that will get the cookie for a windows live/passport.net account by supplying the email and password. This will be used for httpwebrequests on various sites that use windows live accounts. When trying to send an httpwebrequest to the main login page, or any login page for live you are greeted with this message:
Cookies must be allowed
Your browser is currently set to block cookies. Your browser must allow cookies before you can use Windows Live ID.
So I looked into enabling cookies.
According to msdn:
For security reasons, cookies are disabled by default. If you want to use cookies, use the CookieContainer property to enable cookies.
So I attempted to enabled cookies on my webrequest using this code:
Code:
public static string GetHttpSource(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = new CookieContainer();
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;
}
Even after "enabling" cookies, when I load the page I still get told I need to enable cookies.
This is highly disappointing. I also played around with various setting trying to imitate the exact http headers of firefox 3.5 loading the site I'm still getting the same error. Playing around with credentials also did me no luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|