using System.Text.Json; using Microsoft.AspNetCore.Http; namespace Diligent.WebAPI.Business.Extensions { public static class HttpExtensions { //extension method for setting header in response public static void AddHeader(this HttpResponse response, string headerName, int number) { var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; //we want to store content inside header of response in CamelCase format response.Headers.Add("Pagination", System.Text.Json.JsonSerializer.Serialize(number, options)); response.Headers.Add("Access-Control-Expose-Headers", headerName); //giving permission for accessing Pagination header to our client } } }