IIS CORS预检错误经典应用程序池与Windows身份验证

时间:2018-02-21 10:32:01

标签: cors windows-authentication

当我尝试从ajax调用访问IIS托管的ASP:NET MVC应用程序时出现错误。应用程序托管在带有Windows和asp.net模拟身份验证的经典应用程序池中。

即使我在web.config中添加了CORS配置

<add name="Access-Control-Allow-Origin" value="http://localhost:4200" />
    <add name="Access-Control-Allow-Credentials" value="true" />
    <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization, X-PINGOTHER, Origin, X-Requested-With, Accept, Cache-Control" />
    <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />

但是收到CORS 401错误。

我已经在https://evolpin.wordpress.com/2012/10/12/the-cors/中读到,使用经典池和Windows身份验证处理CORS很困难。

在上述情况下,有没有人知道如何处理CORS?

修改

网络版请求:

 (<any>window).DevExpress.JS.Dashboard.getFromServer = function(url, data, queryOptions) {
      return $.ajax($.extend({
        url: url,
        dataType: 'json',
        crossDomain: true,
        xhrFields: {
          withCredentials: true
        },
        data: data,
        headers: { 'software4youclient': this.client }
      }, queryOptions));
    }.bind(this);
    (<any>window).DevExpress.JS.Dashboard.postToServer = function(url, data) {
      return $.ajax({
        method: 'post',
        url: url,
        dataType: 'json',
        crossDomain: true,
        xhrFields: {
          withCredentials: true
        },
        data: data === null || data === undefined ? '' : JSON.stringify(data),
        headers: { 'software4youclient': this.client}
      });
    }.bind(this);

响应Chrome控制台 enter image description here

此致 Naresh

0 个答案:

没有答案