Accessing WCF REST over IIS using CORS works locally, but not from a connected device

I have a set of WCF services for which I have enabled WebInvoke for. One way to access them is through javascript on a simple web page hosted by IIS. To make this work at all, I had to enable CORS, with which I was able to use this guide: http://blogs.microsoft.co.il/idof/2011/07/02/cross-origin-resource-sharing-cors-and -wcf /

However, there is still a problem when I access a web page through my local network from another computer.

To give an example:

Two computers on the network are Comp1 (10.0.0.1) and Comp2 (10.0.0.2). Both IIS and WCF are hosted on Comp1.

Using Firefox, I can access the webpage from Comp1 using: http://10.0.0.1:12345

This works as long as CORS is enabled as described above. If I disable CORS, I get an error saying that CORS is disabled.

If I use Firefox from Comp2 to access 10.0.0.1:12345, I get the same CORS error message, regardless of whether CORS code is enabled on the WCF server. The error message I get here is the same as the one I get on Comp1 if CORS is disabled.

Does anyone have any suggestions on what might be wrong?

Everything (except js and html) is in C # using Visual Studio 2013. Please tell me if I need to add code to get the best help.

+4
1

, CORS IIS. web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

cors .

P.S. - WCF, , CORS.

+1

Source: https://habr.com/ru/post/1611840/


All Articles