How to add a Custom fields to Header in .NET Core Web API ?

Semih Çelikol
5 min readNov 30, 2024

Hello everyone,

Today, I will explain how to add custom fields to the Header section in ASP.NET Core Web API.
(I will explain how to add a mandatory custom field to incoming requests.
You can also use it in responses.)

First, let me briefly talk about the Header object for those who are not familiar with it. (Default Header List is here check this: https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)

We can define the Header object like this:

In the web world, whenever you make a request, whether it’s from a website, a web API, or through a tool like Postman, certain information is automatically or manually sent/filled by the client when sending the request to the server.

For example, open a new tab in your browser, press F12 to open the Network tab, enter any website URL, let’s say https://semihcelikol.com and press enter. When you click on the related site under the GET section, you can see the values automatically sent by your browser within the Header.

--

--

No responses yet