用的WebAPI CORS为XmlHtt prequest [英] CORS with WebAPI for XmlHttpRequest

查看:87
本文介绍了用的WebAPI CORS为XmlHtt prequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道什么是在最优雅的方式(目前)在ASP.NET的WebAPI处理CORS(跨域资源共享),所以我可以用在多个XmlHtt prequest域?我怎么能在每一个类型的请求(GET,POST等)与选项头结合本呢?

Just wanted to know what is the best elegant way (currently available) to handle CORS (Cross-Origin Resource Sharing) in ASP.NET WebAPI so i can use XmlHttpRequest over multiple domains ? How i can integrate this in the headers of every type of request (GEt, POST, etc..) with OPTIONS too ?

谢谢!

推荐答案

Tpeczek有一个很好的研究发现,但是在做我自己的研究香港专业教育学院发现相似,也未尝处理CORS这使您可以配置在您的CORS非常优雅的方式在App_Start文件夹中的配置文件。其所有的处理使用称为Thinkecture一个开源库。查看详情这里:

Tpeczek have a nice found, however while doing my own research ive found something similar and also very elegant ways of handling CORS which enable you to configure your CORS in a config file in App_Start folder. Its all handled using an open source library called Thinkecture. See details here :

<一个href=\"http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/\">http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/

它有许多优点..你可以配置的起源,方法(GET,POST等),获得具体的控制器和动作,同时也让你的控制器的清洁从任何属性。

It have many advantages.. you can configure origins, methods (GET, POST, etc.), access to specifics controllers and actions and it also keep your controllers clean from any attributes.

的WebAPI,IIS和AS​​P.NET MVC的支持!

WebAPI, IIS and ASP.NET MVC is supported !

这篇关于用的WebAPI CORS为XmlHtt prequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆