How to fix 'The underlying connection was closed: An unexpected error occurred on a send'
By FoxLearn 2/16/2024 3:38:43 PM 65
This post shows you how to fix "The underlying connection was closed: An unexpected error occurred on a send." when calling the web api using RestSharp in c# .net through https protocol.
To solve the problem you should set the configuration as the following c# code.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
You can add the code above in the Program class.
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmFluentDesignForm()); } }
I hope so you can solve the problem when using RestSharp library with https protocol.
- How to Call and Consume Web API in Winform using C#
- How to implement simple Memory Cache for Web API
- How to use Web API JWT Token
- Windows Forms: How to Upload a file to Web API from Windows Forms in C#
- Windows Forms: Consume Web API In Winform For File Handling in C#
- ASP.NET Core: How to Upload files in ASP.NET Core Web API using C#
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024
What Are RESTful Web Services?
02/19/2024