To make an HTTP request with a custom body as HTML in C#, you can use the HttpClient
class along with the HttpContent
class. Here's an example:
main.cs514 chars17 lines
In this example, we create a new StringContent
object with our HTML body, set the content type to text/html
, and then make a POST request to http://example.com
with the content. We then read the response and print it to the console.
Note that you will need to add a using statement for System.Net.Http
at the top of your file in order to use the HttpClient
class.
gistlibby LogSnag