请问 怎么处理cookie(request 和response) RRS feed

  • 问题

  • 请问 怎么处理cookie(request 和response)  

    我在response.head里可以看到  set-cookie 但是 request head里没有 cookie

    2014年6月6日 4:21


  • Hi,


    var baseAddress = new Uri("");
    var cookieContainer = new CookieContainer();
    using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
    using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
        var content = new FormUrlEncodedContent(new[]
            new KeyValuePair<string, string>("foo", "bar"),
            new KeyValuePair<string, string>("baz", "bazinga"),
        cookieContainer.Add(baseAddress, new Cookie("CookieName", "cookie_value"));
        var result = client.PostAsync("/test", content).Result;

    更具体一些的信息请到这里询问 现在的这个论坛不是很合适

    Barry Wang
    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年6月9日 9:03