Introduction to Windows Authentication
ASP.NET Core applications can be configured to use Windows Authentication, whereby users are authenticated against their Windows credentials. Windows Authentication is the best choice when your application is hosted on a Windows server and your application is only available on the intranet. In this section, we will learn how to use Windows Authentication in an ASP.NET Core application.
In Visual Studio, choose Windows Authentication in the Change Authentication window while creating a new ASP.NET Core project. If you choose the CLI to create the project, use the --auth Windows
parameters to create a new web app using Windows Authentication, as follows:
dotnet new webapp --auth Windows -o WinAuthSample
If you open launchSettings.json
, you will notice WindowsAuthentication
is set to true
and anonymousAuthentication
is set to false
, as illustrated in the following code snippet. This setting is applicable only when running an application...