404 error when making a POST call from Angular HttpClient to ASP.NET Core 2.2 Web API (with CORS enabled)

前端 未结 2 1748
星月不相逢
星月不相逢 2021-01-27 21:23

I\'ve written a simple ASP.NET Core 2.2 Web API. The POST method always returns a 404, but GET requests succeed.

public cl         


        
2条回答
  •  时光取名叫无心
    2021-01-27 21:44

    Try to add:

    [EnableCors(origins: " * ", headers: " * ", methods: " * ")]
    

    to your Controller class. ( remove with spaces in the quotes )

    More info on Microsoft-Website

提交回复
热议问题