I am working on small web application and I am using angular 7 and asp.net core web api as a back end. I am trying to make http post request with angular. My service returns str
In ASP.NET Core 2.2, we released a new Server which runs inside IIS for Windows scenarios. The issue you are running into looks like: https://github.com/aspnet/AspNetCore/issues/4398.
When sending the XMLHttpRequest, there is a preflight OPTIONS request which returns a status code of 204. This was incorrectly handled by the IIS server, returning an invalid response to the client.
In your ASP.NET Core application, can you please try the workaround for now:
app.Use(async (ctx, next) =>
{
await next();
if (ctx.Response.StatusCode == 204)
{
ctx.Response.ContentLength = 0;
}
});
in the beginning of Configure
method.
This will also be fixed in the next patch release of ASP.NET Core. I will follow up when the patch is released.
Edit: The latest release (2.2.1) should address this problem: https://dotnet.microsoft.com/download/dotnet-core/2.2. Please try and see if the issue is resolved.