How to add custom header to ASP.NET Core Web API response
I am porting my API from Web API 2 to ASP.NET Core Web API. I used to be able to add a custom header in the following manner: HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Headers.Add("X-Total-Count", count.ToString()); return ResponseMessage(response); How does one add a custom header in ASP.NET Core Web API? tmacharia You can just hi-jack the HttpContext from the incoming Http Request and add your own custom headers to the Response object before calling return. If you want your custom header to persist and be added in all API requests across multiple