在新的.NET核心中,我可以为WEB API执行此操作
Response.AddPagination(page, pageSize, totalUsers, totalPages);
public static void AddPagination(this HttpResponse response, int currentPage, int itemsPerPage, int totalItems, int totalPages)
{
var paginationHeader = new PaginationHeader(currentPage, itemsPerPage, totalItems, totalPages);
response.Headers.Add("Pagination",
Newtonsoft.Json.JsonConvert.SerializeObject(paginationHeader));
// CORS
response.Headers.Add("access-control-expose-headers", "Pagination");
}
旧MVC5
怎么办?使用什么而不是
Response.AddPagination(page, pageSize, totalUsers, totalPages);
没关系
var response = HttpContext.Current.Response;