none
wp中WebBrowser 获取Cookie后,再利用Cookie进行HttpWebRequest 获取接口数据出错 RRS feed

  • 问题

  • WebBrowser登陆页面成功后,通过LikesUtils.Cookie = webBrowser_Login.GetCookies()

    获取CookieCollection保存

    HttpWebRequest webRequest = WebRequest.Create(new Uri(url)) as HttpWebRequest;
                    
                    webRequest.CookieContainer = new CookieContainer();
                    webRequest.CookieContainer.Add(new Uri(url), LikesUtils.Cookie);
                   
                    webRequest.Method = "POST";
                    if (webRequest != null)
                    {
                        using (WebResponse webResponse = await webRequest.GetResponseAsync())
                        {
                            using (var rs = webResponse.GetResponseStream())
                            {
                                StreamReader sr = new StreamReader(rs);
                                return await sr.ReadToEndAsync();
                            }
                        }
                    }

    出现以下错误

    A first chance exception of type 'System.Net.CookieException' occurred in System.Net.ni.dll

    2014年7月9日 8:13

全部回复

  • 你好,

    建议你在真机上进行测试,我通过真机测试发现这段代码是OK的。

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年7月10日 5:20
    版主
  • 我也是在真机上测试的,请问手机需要设置什么吗?我的手机是NOKIA 525
    2014年7月10日 13:35