How can I call a web api url from a csharp console application.
"/api/MemberApi"
I don't need anything back from the server. It just needs to be called and the Web API method will execute some code. Although it would be good to record if the call succeeded.
HTTP is a text-based client-server protocol that runs over TCP. Plain HTTP runs over TCP port 80 .
To open an URL in C++, try this: #include <windows. h> . char* linkChar="[http://www.google.com]"; . ShellExecute(NULL, NULL, linkChar, NULL, NULL, SW_SHOWNORMAL); Any more programming questions?
WebClient class is what you need.
var client = new WebClient();
var content = client.DownloadString("http://example.com");
Example of using WebClient in a console app
MSDN Documentation
You can also use HttpWebRequest if you need to deal with a low level of abstraction but WebClient is a higher-level abstraction built on top of HttpWebRequest to simplify the most common tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With