在默认情况下HttpWebRequest 对象的AllowAutoRedirect 为true 所以是取不到它的cookie
要想获取cookie 只需要把 AllowAutoRedirect 设为false
如
Stream GetResponse(string url, ref WebHeaderCollection headers, byte[] data, bool onlyHeader)
{
string ret = string.Empty;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.AllowAutoRedirect = false;
request.Method = "GET";
//request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2224.3 Safari/537.36";
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
if (url.ToLower().Trim().StartsWith("https"))
{
ServicePointManager.ServerCertificateValidationCall