Hi,
I'm currently validating the UI for ASP.NET Core grid component and I run into an issue with the WebApi datasource. When trying the fetch the data it tries to find the data on endpoint "localhost:50050/Customers" however the endpoint is located at the endpoint "localhost:50050/api/Customers". I am following the examples listed here: "http://demos.telerik.com/aspnet-core/grid/webapi". In the demo the route is also configured at "api/{controller}".
Is there any special route configuration I need to add somewhere?
My "Index.cshtml" looks like:
<
div
class
=
"main"
>
@(Html.Kendo().Grid<
Customer
>()
.Name("customerGrid")
.Columns(columns =>
{
columns.Bound(c => c.Id).Title("Tenant");
columns.Bound(c => c.CompanyProfile.CompanyName).Title("Naam");
columns.Bound(c => c.CompanyProfile.Domain).Title("Domein");
columns.Bound(c => c.RelationshipToPartner).Title("Relatie");
})
.Scrollable()
.Groupable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.WebApi()
.Model(model =>
{
model.Id(c => c.Id);
})
.Read(read => read.Action("Get", "Customer"))
)
)
</
div
>
My controller class:
public
class
CustomerController : Controller
{
private
readonly
IAuthenticationService _authenticationService;
private
readonly
ICustomerService _customerService;
private
readonly
ISubscriptionService _subscriptionService;
private
readonly
IUsageService _usageService;
public
CustomerController(
IAuthenticationService authenticationService,
ICustomerService customerService,
ISubscriptionService subscriptionService,
IUsageService usageService
)
{
if
(authenticationService ==
null
)
throw
new
ArgumentNullException(nameof(authenticationService));
if
(customerService ==
null
)
throw
new
ArgumentNullException(nameof(customerService));
if
(subscriptionService ==
null
)
throw
new
ArgumentNullException(nameof(subscriptionService));
if
(usageService ==
null
)
throw
new
ArgumentNullException(nameof(usageService));
_authenticationService = authenticationService;
_customerService = customerService;
_subscriptionService = subscriptionService;
_usageService = usageService;
}
// GET: /<controller>/
public
IActionResult Index()
{
return
View();
}
[HttpGet, Route(
"api/Customers"
)]
public
async Task<
object
> Customers([DataSourceRequest]DataSourceRequest request)
{
var customers = await _customerService
.GetCustomersAsync();
return
new
{ data = customers, totalCount = customers.Count };
}
}