我正在向跨源资源发出一个简单的CORS请求。我假设它是一个POST请求,带有参数,它将归类为简单的CORS请求,因此不需要预先调用飞行。但事实并非如此。
另外,不幸的是因为我使用的是.NET Web API,所以必须在Post请求中的查询字符串上传递任何简单的数据类型。
使用角度$ http发布。
OPTIONS:
Request URL:http://api.local.foundation.com/account/LoginAutomatically?key=null
Request Method:OPTIONS
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:api.local.foundation.com
Origin:http://www.local.foundation.com
Pragma:no-cache
Referer:http://www.local.foundation.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Query String Parametersview sourceview URL encoded
key:null
POST:
Request URL:http://api.local.foundation.com/account/LoginAutomatically?key=null
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:0
Content-Type:application/json;charset=utf-8
Host:api.local.foundation.com
Origin:http://www.local.foundation.com
Pragma:no-cache
Referer:http://www.local.foundation.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Query String Parametersview sourceview URL encoded
key:null
答案 0 :(得分:4)
由于您的请求的内容类型,您的CORS请求已预检。 “application / json”使您的请求成为“非简单”的CORS请求,因此它是预检的。如果您的请求的内容类型是“text / plain”,则在这种情况下不会预检。