在请求和响应之间复制cookie

时间:2018-05-01 15:17:20

标签: c# cookies httpwebrequest httpwebresponse

using (HttpWebResponse httpWebResponse = (HttpWebResponse)templateRequest.GetResponse())
{
    using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
    {
        header = httpWebResponse.Cookies;

这是我的回复饼干,但这是我的要求

HttpWebRequest templateRequest = base.GetTemplateRequest("https://apps.runescape.com/runemetrics/profile/profile?activities=20");

templateRequest.CookieContainer = ???????????

现在如何从请求的响应中获取我的cookie?

我试过

CookieContainer cookies = new CookieContainer();

foreach(Cookie cookie in header)
{
    cookies.Add(cookie);
}
templateRequest.CookieContainer = cookies;

但它不起作用:(

0 个答案:

没有答案