日期:2014-05-17  浏览次数:20841 次

cookie 丢失的问题

string url = "http://xxxx/Login.aspx";
//第一步
CookieCollection cookie = new CookieCollection();
            HttpWebResponse HttpWResp = HttpWebResponseUtility.CreateGetHttpResponse(url, cookie, null, null);
            cookie = HttpWResp.Cookies;           
//第二步
  Dictionary<string, string> para = new Dictionary<string, string>();
            para.Add("UserID", "xxxx");
            para.Add("UserPwd", "xxxx");            
            HttpWebResponse HttpWResp2 = HttpWebResponseUtility.CreatePostHttpResponse(url, para, cookie);         
            HttpWResp2.Dispose();

///第三步
  url = "http://xxxx/List.aspx";
            HttpWebResponse HttpWResp3 = HttpWebResponseUtility.CreateGetHttpResponse(url, cookie, null, null);
            richTextBox1.Text = HttpWebResponseUtility.GetData(HttpWResp3);
            HttpWResp3.Dispose();


在第一步后能获取到cookie, 到第二步完成后cookie就消失了 这是为什么?

HttpWebResponseUtility 是 "周公" 的类 原文出处 "http://blog.csdn.net/zhoufoxcn"

------解决方案--------------------
难道是被你清掉了?