Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

HttpExtensions.cs 771B

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