Windows Phone 7 Http请求添加Cookie的方法

在wp7上添加Cookie请求头可以使用下面的方法:

HttpWebRequest request = System.Net.HttpWebRequest.Create("https://myurl.com") as HttpWebRequest

request.Headers["Cookie"] = "CookieName=CookieValue";

 

在wp7上使用下面的方法来添加Cookie请求头是不成功的:

HttpWebRequest request = System.Net.HttpWebRequest.Create("https://myurl.com") as HttpWebRequest

Cookie c = new Cookie("MyCookieName", myToken, "[valid path]", "[valid domain]");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(new Uri("http://myurl.com"), c);

posted on 2012-01-14 15:15  linzheng  阅读(1739)  评论(4编辑  收藏  举报

导航