2
我發送Post時出現此錯誤。你知道我必須做什麼嗎?登錄到WinApi C#使用Angular登錄到WinApi C#
XMLHttpRequest無法加載http://localhost:56305/Token。對 預檢請求的響應未通過訪問控制檢查:否 「所請求的 資源上存在」Access-Control-Allow-Origin「標頭。因此,'http://localhost:64757'因此不允許 訪問。響應有HTTP狀態代碼400
我的代碼
//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.";
}
};
我想送這樣的事情
我加入這WinApi C#
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
</customHeaders>
</httpProtocol>
,現在我有這個錯誤
的XMLHttpRequest無法加載http://localhost:56305/Token。對於 預檢響應具有無效的HTTP狀態碼400