HttpWebRequest and Set-Cookie header in response not parsed (WP7)

后端 未结 4 679
借酒劲吻你
借酒劲吻你 2021-01-06 02:41

I am trying to get the header \"Set-Cookie\" or access the cookie container, but the Set-Cookie header is not available. The cookie is in the response header, but it\'s not

4条回答
  •  感动是毒
    2021-01-06 03:01

    Try explicitly passing a new CookieContainer:

    CookieContainer container = new CookieContainer();
    container.Add(new Uri("http://yoursite"), new Cookie("name", "value"));
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yoursite");
    request.CookieContainer = container;
    request.BeginGetResponse(new AsyncCallback(GetData), request);
    

提交回复
热议问题