We can enable Cross-Origin Request (CORS) by adding “Microsoft ASP.Net Cross Origin Support” nuget package. Also we can enable CORS thorough Azure portal if we have deployed our web API 2 in azure as a app service.
Enable CORS for web API 2 through Azure portal
- Login to your azure portal through a browser
- Go to app services and click on you app service where web api 2 is hosted.
- Go to setting page and scroll thorough
- You will find API section and under that you will find CORS (I have highlighted in yellow)
- Click on CORS and you can add one or more your client apps. Also you can * mark to grant access to all client applications.