当前位置:编程学习 > C#/ASP.NET >>

C#读取cookie,有些网站读得到,下面这个网站读不到是怎么回事?

有些网站读得到,下面这个网站读不到是怎么回事?恳请赐教
读的到的网站:http://www.google.com.hk/
读不到的网站: http://www.szjs.gov.cn/build/qyxx.aspx

        private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "";

            CookieContainer cookies = new CookieContainer();


            string url = textBox1.Text; 
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            //myHttpWebRequest.Timeout = 20 * 1000; //连接超时
            myHttpWebRequest.Accept = "*/*";
            //myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;)";
            myHttpWebRequest.CookieContainer = new CookieContainer(); //暂存到新实例
            
            cookies = myHttpWebRequest.CookieContainer; //保存cookies
            myHttpWebRequest.GetResponse().Close();
            string cookiesstr = myHttpWebRequest.CookieContainer.GetCookieHeader(myHttpWebRequest.RequestUri); --------------------编程问答-------------------- 那样写不行吧,应该这样:

Response.Cookies["LoginName"].Value = loginName;
Response.Cookies["LoginName"].Expires = 10; --------------------编程问答-------------------- http://www.szjs.gov.cn/build/qyxx.aspx
这个页面没有cookie
不是每个网站都有cookie的
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,