Angular POST and ASP.NET Core Web API : http 401 Unauthorized with windowsAuthentication= true

Discussão em 'Angular' iniciado por Ruth, Maio 26, 2025.

  1. Ruth

    Ruth Guest

    I have separate projects for frontend (Angular) and backend (ASP.NET Core Web API). I have been setup the CORS as well the Windows AD authentication. All that is working well for GET calls, but I am having issues with the POST.

    I am getting following error:


    Access to XMLHttpRequest at 'https://localhost:44314/api/CompletionDate' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
    ​

    In my .NET Core project, I have this config in the launchSettings.json file:

    "windowsAuthentication": true,
    "anonymousAuthentication": false,


    because I need to get the Active Directory username.

    What can I do in order to make the POST and PUT calls work?

    I have already enable cors on the server, and I use withCredentials: true from the client.

    Continue reading...

Compartilhe esta Página