Windows Live ID login via HttpRequest

老子叫甜甜 提交于 2019-12-01 10:02:05

问题


I want interact with one web via HttpRequest/HttpResponse. But the web requires login via Windows Live ID. I go to the live login page, but I can't get any usable response from login page.

The code used to access the login page:

var request = (HttpWebRequest)WebRequest.Create("http://login.live.com/");
request.Timeout = 30000; 
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729)"; 
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; 
request.Headers.Add("Accept-Language", "en-us,en;q=0.5"); 
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); 
request.Headers.Add("Keep-Alive", "300"); 
request.ContentType = "application/x-www-form-urlencoded"; 
request.CookieContainer = new CookieContainer(); 
request.Method = WebRequestMethods.Http.Get; 

var response = (HttpWebResponse)request.GetResponse();

And the response:

Cookies must be allowed

Your browser is currently set to block cookies. Your browser must allow cookies before you can use Windows Live ID.

Cookies are small text files stored on your computer that tell Windows Live ID sites and services when you're signed in. To learn how to allow cookies, see online help in your web browser.

I have no problem with cookies on another web pages and I can't found any way, how to get over this message.

Do you anybody have an idea, how to solve it? Thanks!


回答1:


Try to set the capacity property for CookieContainer object.

....
request.CookieContainer = new CookieContainer(1000); 



回答2:


I found a complete tutorial on how to access Windows Live ID with C# and building the client.

Read here: http://www.devarticles.com/c/a/C-Sharp/Hotmail-Exposed-Access-Hotmail-using-C-sharp/



来源:https://stackoverflow.com/questions/4814594/windows-live-id-login-via-httprequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!