简体   繁体   中英

Cross-Origin Request Blocked: & Reason: CORS header 'Access-Control-Allow-Origin' missing

perhaps this question seems duplicate, but I have my own scenario, ASP.NET MVC application, when I click on check-out it throws following error.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://servicelink?order=%5Bobject%20Object%5D . (Reason: CORS header 'Access-Control-Allow-Origin' missing).

在此处输入图片说明

You will not be able to access this service from javascript because you are on domain aaa.com and the service you are trying to access is on domain bbb.com .This is a security feature implemented by browsers called Same Origin Policy.

Specifying <add name="Access-Control-Allow-Origin" value="*"/> or enabling CORS from your side will not accomplish anything.You need to contact Telemo solutions and ask them to allow requests coming from your server\\domain to call their service through javascript.This is ofcourse very unlikely to happen unless they are your business partner or you have some sort of agreement with them so what you will probably have to do is call their service methods from the C# code.

You can change your javascript to call a server side action\\web method in your code behind and in the code behind write C# code to call the Telemo solutions methods:

使用代理来避免违反相同来源策略

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM