I am developing API in Asp.Net Core 3.1. It's working as expected. I was getting CORS related errors when I was trying to send requests from ajax. but I was not getting any error when I am sending the GET request directly from browsers like Chrome, Edge, and even with the tools like Postman.
Error:
Access to XMLHttpRequest at 'http://server:8080/API/GetMethod?currency=INR' from origin 'http://localhost:63765' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Clientside code:
$.ajax({
type: 'GET',
crossDomain: true,
dataType: 'json',
url: 'myUrl',
success: function(jsondata){
}
})
so my question is why is it not giving the error in browsers and postman. why is it giving error from clientside code? do browsers ignore these errors? from my understanding, it should give the same error even from browsers and postman also.
Update: Though the link context is the same, but I am not satisfied with the answers provided. I have got a better specific answer to my existing question.