剑道上传器在Web.Api中的跨域问题



我已经在我的WEB API项目中启用了Cors !API控制器中的所有其他方法都可以从其他项目访问!

但是剑道上传请求无法到达控制器方法

 $("#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.

这是我的cors

 var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

尝试这种方式对我有效。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
        });

相关内容

  • 没有找到相关文章

最新更新