我已经在我的WEB API项目中启用了Cors! API控制器内的所有其他方法都可以从其他项目访问!
但是kendo上传器请求无法访问控制器方法
$("#files").kendoUpload({
async: {
xhrFields: {
withCredentials: true
},
saveUrl: 'http://localhost:23618/API/test/UploadAttachment',
removeUrl: 'http://localhost:23618/API/test/RemoveAttachment',
autoUpload: true
},
upload: function (e) {
e.data = { contactID: 5 };
},
error: onError
});
错误
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:23617' is therefore not allowed access.
这是我的角色
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
答案 0 :(得分:8)
尝试这种方式对我有用.. http://docs.telerik.com/KENDO-UI/api/javascript/ui/upload#configuration-async.withCredentials
$("#files").kendoUpload({
multiple: false,
async: {
withCredentials: false,
saveUrl: "url",
autoUpload: true
},
success: onSuccess
});