C# 将Cookie设置为非空,但cookiecontainer为空

C# 将Cookie设置为非空,但cookiecontainer为空,c#,.net,httpwebrequest,C#,.net,Httpwebrequest,登录后,将为后续请求生成cookie 我试图通过发送POST请求来获取cookies 在响应头中,有一个set cookies字段,其值如下:value1=value1,value2=value2 但是,我为HttpWebRequest创建的CookieContainer仍然是空的 那么,发生了什么事,我怎样才能把我的烹饪容器填满呢 如有任何建议,将不胜感激 string loginData = "################################"; Co

登录后,将为后续请求生成cookie

我试图通过发送POST请求来获取cookies

在响应头中,有一个set cookies字段,其值如下:value1=value1,value2=value2

但是,我为HttpWebRequest创建的CookieContainer仍然是空的

那么,发生了什么事,我怎样才能把我的烹饪容器填满呢

如有任何建议,将不胜感激

string loginData = "################################";
            CookieContainer cookiecontainer = new CookieContainer();
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://www.ftwilliam.com/cgi-bin/Enter.cgi");
            myRequest.CookieContainer = cookiecontainer;                
            myRequest.Method = "POST";
            myRequest.KeepAlive = true;
            myRequest.AllowAutoRedirect = false;
            myRequest.Referer = "https://www.ftwilliam.com/cgi-bin/Enter.cgi";
            myRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] loginDataBytes = encoding.GetBytes(loginData);
            myRequest.ContentLength = loginDataBytes.Length;
            Stream stream = myRequest.GetRequestStream();
            stream.Write(loginDataBytes, 0, loginDataBytes.Length);
            stream.Close();
            HttpWebResponse res = (HttpWebResponse)myRequest.GetResponse();