You must Sign In to post a response.
  • Category: Webservices

    Access-control-allow-Origin

    Hi there,

    I am very new to webservices, I have created SOAP based service and it is returning the json data while testing, and I hosted the service in the IIS server and tried to call from another system using ajax post method, then it is giving the error "access-control-allow-Origin" in the browser.
    So I have added the header in IIS with value ' * ' the the error was gone and getting the error status 500 (Internal server error).

    Help me to solve this issue.

    Thanks in advance,
    Vijay.
  • #759265
    Hello Vijay,

    Follow the below referenced websites:

    http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work

    http://stackoverflow.com/questions/13400594/understanding-xmlhttprequest-over-cors-responsetext/13400954#13400954

    http://enable-cors.org/server.html

    http://security.stackexchange.com/questions/43639/why-is-the-access-control-allow-origin-header-necessary

    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #759273
    you need to add following lines in web.config to add access control, just add value as '*' so everyone can easily access it. to resolve 505 error you need to put some debugger while call webservice method and check which line throws exception, have you check

    <system.webServer>
    <httpProtocol>
    <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*"/>
    <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
    </customHeaders>
    </httpProtocol>
    </system.webServer>

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments