Answered by:
Enable CORS on Azure Web App

Question
-
Hello,
I would like to enable Cross Origin Resource Sharing (CORS) on my Web App so that I can access external domain's information and place it on my website. Could you please possibly tell me how I can enable CORS on my Azure Web App so that I can access external information? Kindly let me know.
Cheers.Thursday, May 14, 2015 11:45 AM
Answers
-
Unfortunately, at this moment, we don't have support out-of-box to turn on CORS. We will definitely consider the feature in the future. In the meantime, you will have to implement it yourself. One option is to write an HttpModule to handle CORS requests.
Suwatch
- Marked as answer by Syed Irfan Hussain Friday, May 22, 2015 8:01 AM
Thursday, May 21, 2015 5:02 PM
All replies
-
If you want your web app to access other domain resources from its browser ajax, your web app is a client and it does not need to do any special configuration. Instead the external domain resource service needs to support CORS allowing access from your web app domain. See http://www.w3.org/TR/cors/
However if you want your web app to be accessible from other domain, then your web app (as a server) needs to support CORS. To do so, it depends on what technology you use to build your application. If you are using WebAPI, you could enable CORS by http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api.
Suwatch
- Proposed as answer by Shirisha Paderu Friday, May 15, 2015 3:26 PM
- Marked as answer by Shirisha Paderu Monday, May 18, 2015 8:55 AM
- Unmarked as answer by Iram Khan Monday, May 18, 2015 9:07 AM
Thursday, May 14, 2015 5:46 PM -
Hello Suwatch,
Thanks for your information. Basically, my external domain already has CORS enabled on its REST services and I can communicate with it from an application called "SoapUI" or from other web application platforms without any problems. However when I try to achieve the same thing via my WebApp created using Microsoft Azure, I get an error in the console window saying that:
"No 'Access Control Allow Origin' is set on the requested resource. http://xyz.azurewebsites.net is therefore not allowed access".
Kindly let me know how I can achieve this?
Cheers.
Iram Khan
Monday, May 18, 2015 9:07 AM -
Hi,
Please check if [EnableCors]attribute to the TestControllerclass with Orgins,methods and headers as shown here.
Regards,
Shirisha Paderu
- Proposed as answer by Shirisha Paderu Monday, May 18, 2015 4:15 PM
- Marked as answer by Shirisha Paderu Wednesday, May 20, 2015 8:19 AM
- Unmarked as answer by Iram Khan Wednesday, May 20, 2015 8:19 AM
Monday, May 18, 2015 4:15 PM -
I dont have it as an ASP.Net Application. Its just a normal regular website with html, css and javascript. Any possible suggestions on how I can do this Enable CORS setting up on that please?
Iram Khan
Wednesday, May 20, 2015 8:20 AM -
Hi Iram,
I am currently researching to gather more information with regards to your request.
I shall revert back to you with an update at the earliest.
Sincerely appreciate your patience.Regards,
Shirisha Paderu
Wednesday, May 20, 2015 4:20 PM -
The question is more of how to enable CORS from your site. This is little to do with Azure Web Apps or any hoster (or even your own VM). I suggest looking at the http://www.w3.org/TR/cors/. You may get better reply on http://stackoverflow.com/. Cheers,
Suwatch
- Proposed as answer by Shirisha Paderu Wednesday, May 20, 2015 6:09 PM
- Marked as answer by Shirisha Paderu Thursday, May 21, 2015 8:09 AM
- Unmarked as answer by Iram Khan Thursday, May 21, 2015 8:11 AM
Wednesday, May 20, 2015 5:25 PM -
I am basically using the REST API services available to me on my requested domain and I can see that CORS has been enabled on that server and I can communicate with it from other domains. Its only when I try to communicate it from my Azure Web App, I am unable to get a response back. Any suggestions?
Iram Khan
Thursday, May 21, 2015 8:12 AM -
Unfortunately, at this moment, we don't have support out-of-box to turn on CORS. We will definitely consider the feature in the future. In the meantime, you will have to implement it yourself. One option is to write an HttpModule to handle CORS requests.
Suwatch
- Marked as answer by Syed Irfan Hussain Friday, May 22, 2015 8:01 AM
Thursday, May 21, 2015 5:02 PM -
Unfortunately, at this moment, we don't have support out-of-box to turn on CORS. We will definitely consider the feature in the future. In the meantime, you will have to implement it yourself. One option is to write an HTTPModule to handle CORS requests.
Suwatch
Hi @Suwat Ch ,
Does that mean CORS can't be enable for Web API in Azure web app?
Thursday, July 9, 2015 1:48 AM -
Hi Suwatch,
We have a similar requirement with one of external integrations. Do you have any update on whether Azure web app supports CORS?
We are looking for some management option on the web app rather than through the code so that switching it ON and OFF is easy.
Please suggest as what your guidance or approach to the problem would be.
Thanks,
Pratap
Wednesday, December 27, 2017 6:44 PM