string url = "https://data.cathaylife.cn/servlet/HttpDispatcher/KAA0_0100/prompt?newTxRequest=true&syscode=DA&subcode=KAA0";   HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(login_url);   myRequest.Method = "GET";   HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
最后一句执行过了报:“基础连接已经关闭: 发送时发生错误。 ---> System.IO.IOException: 由于远程方已关闭传输流,身份验证失败。”,浏览器是可以访问并能看到源码的。但是程序就不行。求解。各位大虾,帮忙一下。

解决方案 »

  1.   

    string url = "https://data.cathaylife.cn/servlet/HttpDispatcher/KAA0_0100/prompt?newTxRequest=true&syscode=DA&subcode=KAA0";  HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(login_url);  myRequest.Method = "GET";
      myRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13";
      myRequest.Headers.Add("Accept-Language","zh-cn,en-us;q=0.8,zh-hk;q=0.6,ja;q=0.4,zh;q=0.2");
      HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();加上上面2行
      

  2.   

    这样即可
    string url = "https://data.cathaylife.cn/servlet/HttpDispatcher/KAA0_0100/prompt?newTxRequest=true&syscode=DA&subcode=KAA0";    
    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);    
    myRequest.Method = "GET";
    myRequest.Proxy = null;
    myRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0";
    myRequest.Headers.Add("Accept-Language", "zh-cn,en-us;q=0.8,zh-hk;q=0.6,ja;q=0.4,zh;q=0.2");
    myRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
    HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
    MessageBox.Show(new System.IO.StreamReader(myResponse.GetResponseStream(),Encoding.GetEncoding("GB2312")).ReadToEnd());
      

  3.   

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
    是个关键