1
我正在WebAPI中使用CORS支持,并从EntityManager中获取奇怪的结果集,甚至认为我从服务器获得了状态码200和数据。响应得到Breeze在Chrome中状态为OK的错误消息“;”
错误消息(截断):
{message: "; ", statusText: "OK", status: 200, url:"http://localhost:61808/odata/Servers?$filter=Id%20gt%2080&$top=20&$expand=Owner%2CApplications"}
我的DataContext:
(function() {
angular.module('App').factory('datacontext', datacontext);
datacontext.$inject = ['EntityManagerFactory'];
function datacontext(EntityManagerFactory) {
var EntityQuery = breeze.EntityQuery;
var Manager = EntityManagerFactory.newManager();
return {
getServers: getServers
};
function getServers() {
return EntityQuery
.from('Servers')
.expand('owner, applications')
.where('id', 'gt', 80)
.take(20)
.toType('server')
.using(Manager)
.noTracking()
.execute()
.then(success)
.catch(error);
}
function success(response) {
return response.results;
}
function error(error) {
console.log(error);
}
我的WebAPI的web.config:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type, DataServiceVersion, MaxDataServiceVersion" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS, MERGE" />
</customHeaders>
</httpProtocol>
此代码运行正常的IE浏览器。但是,即使有效载荷已交付,Chrome中也会抛出此错误!有任何想法吗?