Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call HTTPS web service method from a .net console application?

I have an ASP.net web application. It sits at https://www.example.com/Private.

I would like to create a .net console application that calls a web method on my ASP.net web application at https://www.example.com/Private/DataCall.

How do I program my .net console application to securely call the web method over HTTPS?

I have done this before in plain HTTP, but for this application, secure communication is essential.

like image 287
Vivian River Avatar asked Feb 20 '26 13:02

Vivian River


1 Answers

Uri uri = new Uri(url);
WebRequest webRequest = WebRequest.Create(uri);   
ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true;
WebResponse webResponse = webRequest.GetResponse();
ReadFrom(webResponse.GetResponseStream());

How do I use WebRequest to access an SSL encrypted site using https?

like image 85
rick schott Avatar answered Feb 23 '26 02:02

rick schott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!