网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 程序请求网站时:基础连接已经关闭: 发送时发生异常
范文
    程序请求网站时?报“基础连接已经关闭: 发送时发生错误。 ---> System.IO.IOException: 由于远程方已关闭传输流,身份验证失败。”求解
    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: 由于远程方已关闭传输流,身份验证失败。”,浏
    览器是可以访问并能看到源码的。但是程序就不行。求解。各位大虾,帮忙一下。
    ------解决方案--------------------
    这样即可
    C# code
    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()); 
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/22 4:51:13