0
votes

My angularjs app is embedded into asp.net mvc app.

From angularjs I'm sending a request to a cross domain like

        $http({
            method: 'POST',
            url: 'http://www.mywebservice.com',
            data: { username: uname, password: pass },
            headers: { 'Content-Type': 'application/json' }
        }).success(function (data, status, headers, config) {
            console.log('status', status);
            console.log('data', status);
            console.log('headers', status);
        });
    }

and I'm getting

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.mywebservice.com. (Reason: CORS request failed).

Is it something that I can fix on asp.net mvc server side inside which this angularjs app is running or is something I should check on mywebservice.com side?

1
You need to use JSONP request json-p.orgmichelem

1 Answers

0
votes

This is happening because you are trying to send a request to a server of a different origin. The issue needs to be resolved on mywebservice.com by allowing your domain to make requests to it. Alternatively you could make the request from your server and then send that to your Angular front end.