问一下怎么获取网页的cookie,我post提交成功了,但是获取不了,
放一下代码,
[C#] 纯文本查看 复制代码 private string PostHtml(string Url, string Postdata)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "post";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.ContentType = "application/x-www-form-urlencoded";//application/x-www-form-urlencoded
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0";
CookieContainer objcok = new CookieContainer();//ASP.NET_SessionId=pv5lnoqpesytpvqfk23raa55; path=/; domain=jw.lzzy.net; HttpOnly
objcok.Add(new Uri("http://jw.lzzy.net"), new Cookie("ASP.NET_SessionId", "pv5lnoqpesytpvqfk23raa55"));
request.CookieContainer=objcok;
Encoding encoding = Encoding.Default;
byte[] buffer = encoding.GetBytes(Postdata);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader read = new StreamReader(stream, Encoding.GetEncoding("utf-8"));
var a = response.Cookies;
return read.ReadToEnd();
}
这是什么况呢??
火狐一下子看到了、、
|