CORS header 'Access-Control-Allow-Origin' missing in aspx

7

I have an application that uses a Java script function and sends a call to consume a web service.

Everything works fine but I do not get anything in the browser.

When I see the console, a message appears CORS header 'Access-Control-Allow-Origin' missing

I have tried to search in several places but I have no answer. Any idea

The code is made in C # and aspx

    
asked by A arancibia 04.05.2016 в 20:46
source

2 answers

3

There is a site dedicated to providing information on CORS for any technology. In your case, as you mention that you use ASP web services, I suppose that the information that will be useful to you is about IIS7: link

Giving you a quick glance, you will have to modify your web.config (where your web services are) to include the following information.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>
    
answered by 04.05.2016 в 23:27
0

If the request you make from the page with JavaScript is to another domain, you can not do it through the cross -origin policy .

What the error tells you is that indicating the HTTP header Access-Control-Allow-Origin in the source order of the page itself, you can consume a web service in another domain.

If the page is on example.com and the order is made to servicio.com, on the example.com server you must add an HTTP header that is

Access-Control-Allow-Origin: servicio.com

In any web server engine you can add an HTTP header without much difficulty.

    
answered by 04.05.2016 в 22:02