Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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
Angularjs Web Api 2是否有一个带有503错误的选项请求?_Angularjs_Asp.net Web Api2 - Fatal编程技术网

Angularjs Web Api 2是否有一个带有503错误的选项请求?

Angularjs Web Api 2是否有一个带有503错误的选项请求?,angularjs,asp.net-web-api2,Angularjs,Asp.net Web Api2,我已经尝试了所有关于CORS与Web Api 2和Angular的问题的方法 我已经下载了用于CORS的Web API的nuget包 我已在控制器中启用CORS 我在api web.config中添加了以下内容: <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Me

我已经尝试了所有关于CORS与Web Api 2和Angular的问题的方法

我已经下载了用于CORS的Web API的nuget包

我已在控制器中启用CORS

我在api web.config中添加了以下内容:

<httpProtocol>
<customHeaders>
  <add name="Access-Control-Allow-Origin" value="*" />
  <add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, HEAD" />
  <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
</customHeaders>
</httpProtocol>
我已经将EnableCorsAttribute放在了控制器的顶部

在此之后,当我发表我的帖子时,我收到了来自fiddler内部的以下请求:

OPTIONS http://api.carb-stage.derivesystems.com/api/Recaptcha/Post HTTP/1.1
Host: api.carb-stage.derivesystems.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Request-Method: POST
Origin: http://carb-stage.derivesystems.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Access-Control-Request-Headers: accept, content-type
Accept: */*
Referer: http://carb-stage.derivesystems.com/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
这是我得到的回应:

HTTP/1.1 503 Service Unavailable
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 29 Sep 2015 20:10:49 GMT
Connection: close
Content-Length: 326

是的,在处理CORS请求时,选项请求很常见。你的问题?您必须确保您的服务器将响应选项请求。@KevinB-有什么我可以检查的,看看我的服务器是否能处理这个问题。我必须在web.config中添加一些内容吗?或者它是IIS中的一个设置?我不知道需要更改什么,我已经有一段时间没有使用asp.net了。但是我很确定如果配置正确,你的服务器会支持它。也许你会看到
HTTP/1.1 503 Service Unavailable
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 29 Sep 2015 20:10:49 GMT
Connection: close
Content-Length: 326