No 'Access-Control-Allow-Origin' header is present on the requested resource. RRS feed

  • Question

  • Hello ,

    •  I have created a Rest Service by WCF which get data from data base and return json .
    •  I have create w java script file which have a function that use $.ajax Get to call the Rest Service.
    •  I used the script file in the custom web part . Then I added the web part in SharePoint page .
    •  When I test the web part I get this error  "XMLHttpRequest cannot load http://localhost:2020/GovernmentService.svc/owner/11111. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access." .
    •  I open web.config and add the following tag  , but I got the same error

               <add name="Access-Control-Allow-Origin" value="http://localhost" />


              <add name="Access-Control-Allow-Origin" value="http://machinename" />


      How Can I fix this issue ?



    Wednesday, August 12, 2015 10:13 AM

All replies