首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于MVC包装器和Web的KendoUI网格

基于MVC包装器和Web的KendoUI网格
EN

Stack Overflow用户
提问于 2013-11-07 16:35:39
回答 2查看 1.2K关注 0票数 1

我正在使用带有ASP.Net MVC包装器的Kendo网格。我的网格数据源定义如下:

代码语言:javascript
复制
.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))
      )

因此,人们会期望GET url将以[server]/[app]/api/ProjectMilestone的形式生成。

但在我的例子中,承载网格的页面位于以下网址:[server]/[app]/Project。这将导致GET url作为[server]/[app]/Project/api/ProjectMilestone生成,当然服务器返回错误404未找到。

请告诉我如何让GET url生成为[server]/[app]/api/ProjectMilestone

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-08 16:07:58

正确的方法是将数据源定义为:

代码语言:javascript
复制
.Read(read => read.Url(Url.RouteUrl("DefaultApi", new { httproute ="", controller="ProjectMilestone" })).Type(HttpVerbs.Get))
.Create(create => create.Url(Url.RouteUrl("DefaultApi", new { httproute ="", controller="ProjectMilestone" })).Type(HttpVerbs.Post))
.Update(update => update.Url(Url.RouteUrl("DefaultApi", new { httproute ="", controller="ProjectMilestone" })).Type(HttpVerbs.Put))
.Destroy(destroy => destroy.Url(Url.RouteUrl("DefaultApi", new { httproute ="", controller="ProjectMilestone" })).Type(HttpVerbs.Delete))

摘自this的答案。

票数 2
EN

Stack Overflow用户

发布于 2013-11-07 19:06:10

您是否尝试过使用控制器名称和操作的重载,对控制器使用"api“,对操作使用"ProjectMilestone”?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19841453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档