C# : System.Net.WebException: The underlying connection was closed

后端 未结 2 496
南方客
南方客 2021-01-22 12:04

I have the following code :

String url = // a valid url
String requestXml = File.ReadAllText(filePath);//opens file , reads all text and closes it
byte[] bytes =         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 12:51

    Adding this line of code solved the problem for me:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    

    This was taken from: https://our.umbraco.com/forum/using-umbraco-and-getting-started/74628-the-underlying-connection-was-closed-an-unexpected-error-occurred-on-a-send

提交回复
热议问题