我的设置是以下剑道UI电网的OData
- IIS 8.5
- KendoUI
- Server 2012中
- MSSQL
我非常新的OData的,只发现了约它由于kendo ui,它似乎是从sql获取数据的最佳方式。
我成功地在C#上创建了一个asp.net web应用程序,以便能够从我的服务器获取odata,如果我在浏览器中使用它,它就像一个魅力,我得到我的信息json fromatted。
因为即时通讯新的这里我可能有错误在这里,但我的REST风格的服务是在一个单独的网站比我的主要网站,我将使用剑道网格。我有端口8080上的Restful,而我的端口80上的正常站点
这是我的代码,我的网格正在生成。
$("#vehiclesGrid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: {
url: "http://mydomain(security issues):8000/odata/GetVehiclesConfigureds",
dataType: "json"
},
schema:{
model:{
fields:{
displayName:{type: "string"},
sensor:{type: "number"},
alertFlag:{type: "number"}
}
}
}
}
},
height: 550,
groupable: true,
sortable: true,
columns: [{
field: "displayName",
title: "Display Name",
width: 100
}, {
field: "sensor",
title: "# of Sensors"
}, {
field: "alertFlag",
title: "Alert Pending"
}]
});
<div id="vehiclesGrid"></div>
和控制台我得到以下错误的:
XMLHttpRequest cannot load http://mydomain(security issues):8000/odata/GetVehiclesConfigureds?%24inlinecount=allpages. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://mydomain(security issues)' is therefore not allowed access.
如果我去开发工具在网络部分,我可以看到被正确检索到的OData的信息,但网格是空的。所以我不知道它为什么不显示它,或者即使它在控制台上与该错误有关。
我一定要安装的东西这个工作?我的编译器无法解析EnableCors() –
另外,我的控制器中的起源应该是Web服务端口还是站点? –
@ pato.llaguno起源是您的网站的端口 - 您的请求的来源/起源Odata控制器 – Jaya