8.10Configuring Windows Authentication

Created on Aug 17, 2026~2 min read

Windows authentication is a security mechanism provided by Microsoft that verifies the identity of users or entities, ensuring that their access to systems, network resources, and applications complies with security policies. This mechanism is typically used in the Windows operating system, allowing users to log in to the system or to applications that depend on this mechanism without manually entering a username and password.

In some traditional Web application systems deployed on Windows servers, sending HTTP remote requests may require enabling Windows authentication. The following are two common configuration approaches:

cs
// Configure the default clientservices.AddHttpClient(string.Empty)    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler    // Or use SocketsHttpHandler    {        UseDefaultCredentials = true    });// Configure a specific clientservices.AddHttpClient("furion")    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler    // Or use SocketsHttpHandler    {        UseDefaultCredentials = true    });

2. Manually entering the Windows system username and password

cs
// Configure the default clientservices.AddHttpClient(string.Empty)    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler    // Or use SocketsHttpHandler    {        Credentials = new NetworkCredential("windowsLoginUsername", "windowsLoginPassword"),        PreAuthenticate = true    });// Configure a specific clientservices.AddHttpClient("furion")    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler    // Or use SocketsHttpHandler    {        Credentials = new NetworkCredential("windowsLoginUsername", "windowsLoginPassword"),        PreAuthenticate = true    });

Through the configuration above, you can choose to use the current system user or manually enter credentials to enable Windows authentication as needed.