Cors抛出错误“拒绝访问”

本文关键字:拒绝访问 错误 出错 Cors | 更新日期: 2023-09-27 18:14:12

我已经构建了一个SharePoint应用程序,它使用Jquery调用托管在IIS中的Webservice。

SharePoint服务器,特别是应用程序将托管在SharePoint下的域

https://qsspapp-3b9352b780820d.qsapps.com/teams/...

我的调用如下所示

private loadStates() {      
         $.support.cors = true; 
         $.ajax({
             type: "GET",
             cache: false,
             crossDomain:true,
             url: "http://myservice.de/api/controller/getavailablestates",
             success: (results) => {
                 console.log(results.Data);
                 this.availableStates.removeAll();
                 $.each(results.Data, (indexedDB, item: TableResultItem) => {
                     this.availableStates.push(new DataObjects.SelectionItem(item.rEQSTField, item.rEQST_DSCRField));
                 });
             },
             error: (jqXHR: any, textStatus: any, errorThrown: any) => {
                 console.log("loadStates Error: " + errorThrown);
             },
         });
     }

我的服务Web。Config包含以下cors的设置:

<system.webServer>
  <httpProtocol>
    <customHeaders>
      <add name="Access-Control-Allow-Origin" value="*" />
    </customHeaders>
  </httpProtocol>...

当我调用这个方法时,它告诉我错误"访问被拒绝"。

我错了吗?

Cors抛出错误“拒绝访问”

下面使用webconfig

<system.web>
  <authentication mode="None" />
  <authorization>
    <allow users="?" />
  </authorization>
</system.web>

希望对您有所帮助....

我终于找到了可行的解决方案。

我在一个HTTPS系统(SharePoint)上工作,并向一个HTTP系统(Service Dispatcher)进行调用。这适用于大多数浏览器,但不适用IE....(坏事. .)

解决方案:

我必须为服务分派器创建一个HTTP绑定,并添加分派器Url作为插入站点。

在那之后它工作。

谢谢你的帮助!:)