Why does this code hang on reaching the first ReadLine from a StreamReader?

[亡魂溺海] 提交于 2019-12-02 15:16:58
Henk Holterman

I think you should return to basics:

public static string SendXMLFile(string xmlFilepath, string uri, int timeout)
{
    using (var client = new WebClient())
    {                
        client.Headers.Add("Content-Type", "application/xml");                
        byte[] response = client.UploadFile(uri, "POST", xmlFilepath);
        return Encoding.ASCII.GetString(response);
    }
}

and see what works and what the server thinks of your file.

When you really need a TimeOut then see this answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!