I solved this problem after not finding the solution on Stackoverflow, so I am sharing my problem here and the solution in an answer.
After enabling a cross domain policy in my .NET Core Web Api application with AddCors, it still does not work from browsers. This is because browsers, including Chrome and Firefox, will first send an OPTIONS request and my application just responds with 204 No Content.
Add a middleware class to your project to handle the OPTIONS verb.
Then add
app.UseOptions();
this as the first line in Startup.cs in the Configure method.I know it has been answered. Just answering with the updated information. So it would help others.
Its now its inbuilt into asp.net core framework.
Just follow https://docs.microsoft.com/en-us/aspnet/core/security/cors
and replace
with