Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.13 KB

File metadata and controls

36 lines (28 loc) · 1.13 KB
title page_title description slug position
Headers
Headers | Telerik UI DataSource HtmlHelper for ASP.NET Core
Learn how to set request headers in the DataSource HtmlHelper for ASP.NET Core (MVC 6 or ASP.NET Core MVC).
htmlhelper_datasourceheaders_aspnetcore
3

Headers

As of the Telerik UI for ASP.NET Core R3 2019 release, you can set request headers by using the Headers configuration option of the DataSource.

The following example demonstrates how to use the Headers option to set a request header.

    @(Html.Kendo().DataSource<OrderViewModel>()
        .Name("myDataSource")
        .Ajax(d => d.Read(r => r.Action("ReadOrders", "Home").Headers(new { header1 = "test" })))
    )

    <script>
        myDataSource.read(); // The header will be set in the request that is sent to the HomeController ReadOrders action.
    </script>  

    public IActionResult ReadOrders([DataSourceRequest]DataSourceRequest request)
    {
        // Orders can be IQueriable or IEnumerable.
        return Json(orders.ToDataSourceResult(request));
    }

See Also