kendo uploader Web.Api中的跨域问题

时间:2015-09-07 07:22:37

标签: asp.net-mvc kendo-ui asp.net-web-api kendo-upload

我已经在我的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);

1 个答案:

答案 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
        });