Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Cors向我抛出错误“访问被拒绝”_C#_Jquery_Iis_Sharepoint_Cors - Fatal编程技术网

C# Cors向我抛出错误“访问被拒绝”

C# Cors向我抛出错误“访问被拒绝”,c#,jquery,iis,sharepoint,cors,C#,Jquery,Iis,Sharepoint,Cors,我构建了一个SharePoint应用程序,它使用Jquery调用IIS中托管的Web服务 SharePoint服务器(特别是应用程序)将托管在域下的SharePoint中 https://qsspapp-3b9352b780820d.qsapps.com/teams/... 我的电话如下 private loadStates() { $.support.cors = true; $.ajax({ type: "GET"

我构建了一个SharePoint应用程序,它使用Jquery调用IIS中托管的Web服务

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);
             },

         });

     }
My Service Web.config包含以下cors设置:

<system.webServer>
  <httpProtocol>

    <customHeaders>

      <add name="Access-Control-Allow-Origin" value="*" />
    </customHeaders>
  </httpProtocol>...
当我调用此方法时,它认为错误访问被拒绝

我做错了什么?

在网络配置中使用下面的命令


希望这有帮助……

我终于找到了解决办法

问题

我在HTTPS系统SharePoint上工作,并调用HTTP系统服务调度器。 这适用于大多数浏览器,但不适用于IE。。。。坏事

解决方案:

我必须为服务调度器创建一个HTTP绑定,并将调度器Url添加为插入站点

在那之后它就开始工作了


谢谢你的帮助!:

我希望您需要在ajax requestYes中提及用户名凭据,但我目前没有身份验证例程。所以这不可能是问题所在。该服务也被授予匿名访问权限。没有您的错误明确指出问题在于身份验证,因此您获得访问权限的原因被拒绝。我希望您需要检查一下服务器again@AntoKing在这种情况下,访问被拒绝很可能与身份验证无关。我猜您的服务器上不支持选项动词,因此没有CORS。使用Fiddler查看实际发出的请求以及实际发送的头。
<system.web>
  <authentication mode="None" />
  <authorization>
    <allow users="?" />
  </authorization>
</system.web>