I'm using Kendo UI grid with ASP.Net MVC Wrappers. My grid datasource is defined as follows:
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.Code);
})
.Read(read => read.Url("api/ProjectMilestone").Type(HttpVerbs.Get))
.Create(create => create.Url("api/ProjectMilestone").Type(HttpVerbs.Post))
.Update(update => update.Url("api/ProjectMilestone").Type(HttpVerbs.Put))
.Destroy(destroy => destroy.Url("api/ProjectMilestone").Type(HttpVerbs.Delete))
)
So one would expect that the GET url would be generated as [server]/[app]/api/ProjectMilestone
.
But in my case, the page on which the grid is hosted is at the following URL: [server]/[app]/Project
.
This results in the GET url being generated as [server]/[app]/Project/api/ProjectMilestone
, and of course the server returns error 404 not found.
Please tell me how I can have the GET url generated as [server]/[app]/api/ProjectMilestone
instead.
Have you tried the overload that takes a Controller name and action using "api" for the controller and "ProjectMilestone" for the action?
Turns out the correct approach is to define the datasource as follows:
as taken from this answer.