Tested in Postman
and works fine.
In Browser I get this Error:
Access to XMLHttpRequest at 'http://localhost:5081/api/Accounting/GetSales' from origin 'https://localhost:44426' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Asp Net Core Project with Angular and .Net6
[DisableCors]
[HttpGet("GetSales")]
public IEnumerable<SaleDto> GetSales()
{
var result = _context.Sales.Select(x => new SaleDto
{
AccountName = x.Account.Name,
CategoryName = x.Category.CategoryName,
SaleDate = x.SaleDate,
SaleId = x.SaleId,
SaleValue = x.SaleValue,
});
return result;
}
DisableCors
defeats that – Chowder