Enable CORS in .Net Web Api 2
What is CORS?
Cross-origin resource sharing (CORS) is a mechanism that enables many resources (e.g. fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain from which the resource originated. (wiki)
- You need to install Microsoft.AspNet.WebApi.Cors
PM> Install-Package Microsoft.AspNet.WebApi.Cors
2. In your WebApiConfig.cs in Register method
3. In you Web.config
Make sure you have the following
4. And the last step is to use Cors attributes in your controller like this
If you still have issues, please comment this article.