Home Tags Privacy About

All posts tagged with "HttpClient"

The HttpClient is a class used to make HTTP requests and receive HTTP responses. It has methods for all the different HTTP verbs: GET, PUT, POST, DELETE etc

Page 1 of 2 Older Posts →

C# - How to make HTTP / REST calls using the HttpClient

C# has great built-in support for making HTTP requests using the HttpClient. Using this client you can Put, Post, Get, Delete and much more using your »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient 29 August 2022

C# HttpClient - How to send a Delete request with or without a body

Using the HttpRequestMessage together with the HttpClient you can easily send a HTTP Delete request in C#. Below we have a delete endpoint on https://localhost: »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient 27 August 2022

C# HttpClient - How to set the Content-Type header for a request

This post describes how to make a HTTP request with a specific content-type using the HttpClient in C#. Using the HttpClient you can POST JSON or »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient 26 June 2022

C# - Should you reuse your HTTPClient? or dispose it after every request?

I have always been told to reuse the HttpClient throughout the application lifetime for better performance and stability. If you search for why, there are quite »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient 06 June 2022

C# - How to add or remove headers using the HttpClient

You can set default headers on the HttpClient using the DefaultRequestHeaders property: _httpClient.DefaultRequestHeaders.Add("MyFantasticHeader" ,"MyFantasticValue"); var result = await _httpClient.GetAsync( »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient 06 June 2022

C# - How to set a BaseAddress using the HttpClient

If you would rather work with relative URLs than absolute URLs you can use the BaseAddress [https://docs.microsoft.com/en-us/dotnet/api/system.net.http. »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on HttpClient, C# 08 May 2022

C# - Set the URL per request using the HttpClient

This might seem trivial, but since I got the question the other day I might as well make a post about it. Using the HttpClient [https: »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on HttpClient, C# 08 May 2022

C# HttpClient - How to use basic authentication and set the HTTP authorization header

Basic authentication is becoming a rare sight, however it is still quite widely used due to its simplicity. In C#, using the HttpClient and HttpRequestMessage you »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on C#, HttpClient, Web and HTTP 08 January 2022

C# - How to set the encoding of a request using the HttpClient

This post demonstrates how you can change the Encoding when using the HTTPClient in C#. You can do this by setting the encoding on the StringContent »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on HttpClient 26 December 2020

C# - How to PUT or POST JSON using the HttpClient in .Net

In this post I demonstrate how you can PUT or POST JSON using the HTTPClient in C#. The simplest way to do this is using the »

Peter Daugaard Rasmussen Peter Daugaard Rasmussen on HttpClient, C#, Web and HTTP 24 October 2020
Page 1 of 2 Older Posts →
  • Rss
  • Twitter
  • LinkedIn
  • profile for Peter Rasmussen at Stack Overflow, Q&A for professional and enthusiast programmers
Peter Daugaard Rasmussen - developer, Consultant, Blogger © 2025 Privacy policy