I get this error when I send Post. Do you know what I have to do? Login to WinApi C#
XMLHttpRequest cannot load http://localhost:56305/Token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:64757' is therefore not allowed access. The response had HTTP status code 400.
My code
//linki
$scope.addLink = "http://localhost:56305/Token";
$scope.addData = function () {
if ($scope.password != "" && $scope.email) {
$http({
method: "POST",
url: $scope.addLink,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
headers: {'X-Requested-With' :'XMLHttpRequest'},
data: { grant_type: 'password', username: $scope.email, Password: $scope.password }
}).then(function mySucces(response) {
$scope.stateHideError = true;
$scope.stateHideSuccess = false;
Authorization.go('carInsurance');
}, function myError(response) {
$scope.stateHideError = false;
$scope.stateHideSuccess = true;
$scope.error = "Wystąpił błąd - Problem z wysłaniem parametrów";
});
}
else {
$scope.stateHideError = false;
$scope.stateHideSuccess = true;
$scope.error = "Wystąpił błąd - nie podałeś wszystkich wymaganych wartości.";
}
};
I would like send something like this
I added this to WinApi C#
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
</customHeaders>
</httpProtocol>
and now I have this error
XMLHttpRequest cannot load http://localhost:56305/Token. Response for preflight has invalid HTTP status code 400

