小编Jed*_*rke的帖子

无法从传输连接读取数据:C# 中的远程主机强制关闭了现有连接

我有一个代码,我在其中发送 URL 请求并接收响应并将其存储为字符串

public String GenerateXML(String q)// Here 'q' is the URL 
{
    // Generating the XML file for reference
    // Getting the response in XML format from the URL

    Debug.WriteLine("The Http URL after URL encoding :" + q);
    try
    {
        Uri signs1 = new Uri(q);
        //Debug.WriteLine("The Requested URL for getting the XML data :" + re);

        WebRequest request1 = WebRequest.Create(signs1);

        HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();

        //HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();

        Stream receiveStream = response1.GetResponseStream();

        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

        String …
Run Code Online (Sandbox Code Playgroud)

c# webrequest remote-host httpwebrequest ioexception

5
推荐指数
2
解决办法
3万
查看次数