旧mvc5中的C#MVC响应

时间:2016-11-04 21:04:37

标签: c# asp.net-mvc rest

在新的.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;

0 个答案:

没有答案