Angular , .NET Core, IIS Express and Windows Authentication
2 years ago I have written about .NET Core Windows Authentication :http://msprogrammer.serviciipeweb.ro/2016/09/26/asp-net-core-and-windows-authentication/
The idea was that for Windows authentication this is mandatory in Web.Config:
forwardWindowsAuthToken="true"
Now I want to show how to achieve the same in IIS Express .NET Core as backend and Angular for front end
For .NET Core / IIS Express
1. Configure IISExpress : https://www.danesparza.net/2014/09/using-windows-authentication-with-iisexpress/
On short: find %userprofile%\documents\iisexpress\config\applicationhost.config or %userprofile%\my documents\iisexpress\config\applicationhost.config and put
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
2. On your project: Put in launchSettings.json :
“windowsAuthentication”: true,
“anonymousAuthentication”: false,
3. Optional: To verify add an Action that returns
(this.User?.Identity?.Name ?? "Not ad enabled")
For Angular
return this.http.get(url,{
withCredentials: true
});
4. ASP.NET Core 2.1
https://github.com/aspnet/Home/releases/tag/2.1.0
Windows authentication is not enabled after creating project with the Windows authentication option selected
When creating a template with Windows authentication, the settings to enable Windows authentication in launchSettings.json are not applied.
Workaround: Modify launchSettings.json as follows:
“windowsAuthentication”: true,
“anonymousAuthentication”: false,
Leave a Reply