[英]which http methods allowed in “*” when enabling CORS in web api
I have implemented CORS in web API by using Cors library. 我已经通过使用Cors库在Web API中实现了CORS。
[EnableCors(origins: "*", headers: "*", methods: "*")]
and in webapi config file 并在webapi配置文件中
config.EnableCors();
I called api using POST method, still I was getting error in console i:e No 'Access-Control-Allow-Origin' header is present on the requested resource. 我使用POST方法调用api,但仍然在控制台i中出错:e请求的资源上没有'Access-Control-Allow-Origin'标头。
Then I changed 然后我改变了
[EnableCors(origins: "*", headers: "*", methods: "*")]
To 至
[EnableCors(origins: "*", headers: "*", methods: "GET, POST, PUT, DELETE, OPTIONS")]
Then its started working, my question why it doesn't work with allowed methods using "*" 然后它开始工作,我的问题是为什么它不能与使用“ *”的允许方法一起工作
The wildcard for Access-Control-Allow-Methods
is not yet supported by all browsers. 并非所有浏览器都支持
Access-Control-Allow-Methods
通配符。
Browser support is also tracked by MDN here , so future readers may want to check that too in case this answer becomes outdated. 浏览器支持也由MDN跟踪在这里 ,所以未来的读者可能要检查过的情况下,这个答案变得过时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.