0
votes

I'm probably missing something but till now haven't figure it out.

I have a MVC application which listens on the web default port (i.e. 80), at the end of the interaction with the user, it sends an ajax post request (using jquery) to a WCF 4 REST service which listens on port 90, sadly enough, I'm not allowed to do so because of the brower same origin policy security issue.

I read that Chrome, Safari and firefox support by default the CORS protocol which allow cross domain requests.

In my server I've added to the response's headers the following: Access-Control-Allow-Origin,Access-Control-Allow-Methods,Access-Control-Allow-Headers and Access-Control-Max-Age.

from what I saw all the cors plugins handle microsoft xdr object and doesn't change the xhr default behavior.

Any help will be appriciated,

Thanks,

Ron

1
Adding the Access-Control-Allow-Origin header should work and it has to be sent from the service listening on port 90 (just to make sure).stewe

1 Answers

0
votes

Hey stewe thanks for the reply, adding the headers to the service response didn't do the trick. But the following did (Cors solution):

a) I was using jquery v 1.5.1 and found out that someone report a bug related to cross domain requests which was fixed in later version.

b) In the Service web config I've decalred the following:

 <httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*"/>
    <add name="Access-Control-Allow-Headers" value="Content-Type"/>
   </customHeaders>
</httpProtocol> 

This sln relevant only for browsers which support CORS protocol (i.e. not IE) for that we can use easyxdm.

Eventually, I've decided not to expose my service to the user, but through an UI.

Thanks,

Ron