WCF restful Resolve: Access-Control-Allow-Origin
16:32Introduction
In this article I show how to resolve error No 'Access-Control-Allow-Origin' header is present on the requested resource. When we create restful service in WCF.Error Message
This is the following error when we want to access restful WCF service:Why We Get This Error
This type of error coming when our service was running on a different server and it was not configured to accept a request from any origin.Solution
This error can be resolve by enabling CORS: Cross Origin Resource Sharing in our service.Add the following code in web.config file.
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol> <modules runAllManagedModulesForAllRequests="true" /> <directoryBrowse enabled="true" /> </system.webServer>
0 comments