【发布时间】:2012-06-04 19:52:06
【问题描述】:
我正在关注Steve Sanderson 的一个非常简单的教程,看起来脚手架脚本没有调用我的 webapi:
cshtml代码:
@(Html.UpshotContext().DataSource<Yoga.Controllers.YogaController>(x => x.GetAllBugs()))
生成的脚本:
upshot.dataSources = upshot.dataSources || {};
upshot.metadata({...});
upshot.dataSources.AllBugs = upshot.RemoteDataSource({
providerParameters: { url: "/api/Yoga/", operationName: "GetAllBugs" },
entityType: "BugView:#Yoga.Models",
bufferChanges: false,
dataContext: undefined,
mapping: {}
});
它是在页面加载后调用的:
$(function() {
var dataSource = upshot.dataSources.AllBugs;
dataSource.refresh(function(results)){
//error here, `result` is an null object
alert(results);
});
});
我在控制器中的 GetAllBugs() 成员处放置了一个断点,但它从未被命中。
但是,当我直接访问 uri 时,http://localhost/api/yoga/getallbugs 我得到了预期的结果。 (并且断点被命中)
我似乎无法弄清楚脚手架的结果脚本发生了什么。
谢谢
【问题讨论】:
标签: javascript asp.net-mvc asp.net-mvc-4 asp.net-web-api upshot