httpwebrequest获取cookie不全
比如访问Uhttp://my.fundon.cn/code
用httpwatch获取出来
JSESSIONID Sent 9B57DBFD7F54862AFF2142B9CDFEDAA2.tels / my.fundon.cn (Session)
HCode Received "yFPHQ4HGaAs=" / fundon.cn (Session)
而通过httpwebrequest获取不到第二个
这个页面是验证码,我是这样写的
CookieCollection cookies = new CookieCollection();
//this.pbImageCode.ImageLocation = codeurl;
HttpWebRequest httpWebRequest;
HttpWebResponse webResponse;
byte[] byteRequest = { };
httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(codeurl);
CookieContainer co = PublishVoid.CodeCookie;
co.Add(new Uri(codeurl), cookies);
httpWebRequest.CookieContainer = co;
PublishVoid.CodeCookie = co;
httpWebRequest.Accept = "*/*";
httpWebRequest.Referer = codeurl;
httpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)";
httpWebRequest.Method = "GET";
httpWebRequest.KeepAlive = true;
webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
Image original = Image.FromStream(responseStream);
Bitmap bitMap = new Bitmap(original);
this.pbImageCode.Image = bitMap;