Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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/4/powerbi/2.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
Cors 为什么webapi 2未能通过IIS的飞行前选项请求_Cors_Asp.net Web Api2 - Fatal编程技术网

Cors 为什么webapi 2未能通过IIS的飞行前选项请求

Cors 为什么webapi 2未能通过IIS的飞行前选项请求,cors,asp.net-web-api2,Cors,Asp.net Web Api2,我有一个非常简单的webapi 2应用程序,它只是一个com dll的传递,正在处理Get请求,但在IIS中的localhost上运行api时,由于CORS错误导致一个Post请求失败。当我从VisualStudio在节点服务器和IIS Express中分别在不同的本地主机端口上运行客户端和服务器时,它会工作 我在webapiconfig.cs文件中全局启用了CORS: 公共静态类WebApiConfig public static void Register(HttpConfigu

我有一个非常简单的webapi 2应用程序,它只是一个com dll的传递,正在处理Get请求,但在IIS中的localhost上运行api时,由于CORS错误导致一个Post请求失败。当我从VisualStudio在节点服务器和IIS Express中分别在不同的本地主机端口上运行客户端和服务器时,它会工作

我在webapiconfig.cs文件中全局启用了CORS: 公共静态类WebApiConfig

      public static void Register(HttpConfiguration config)
      {
         // Web API configuration and services

         // Web API routes
         config.MapHttpAttributeRoutes();

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

         config.Routes.MapHttpRoute(
             name: "DefaultApi",
             routeTemplate: "api/v1.0/{controller}"
         );
      }
当我从angular发出http请求,并且服务器在本地主机上的IIS中运行时,我得到以下错误

这就是网络流量的样子


它一直在工作,直到最近。我所做的唯一更改是在客户端和com dll中。但这篇文章在Fiddler看来效果不错。我是http的新手,所以有人能建议如何解决这个问题吗?

这不是CORS配置本身的问题。看起来还可以。在WEB API中仔细检查您的路由。我认为您必须更改访问资源的路径。

这不是CORS配置本身的问题。看起来还可以。在WEB API中仔细检查您的路由。我认为您必须更改访问资源的路径。

应用程序中的唯一路径在问题的代码中。应用程序中的唯一路径在问题的代码中。我有同样的问题,您解决了吗?错误消息是错误的。这个问题实际上是com服务器中的一个错误,我最终找到了另一种方法。我也有同样的问题,你解决了吗?错误消息是错误的。问题实际上是com服务器中的一个错误,我最终找到了另一种方法。