Need to login automatically based on windows login
Need to open windows login prompt for another API call
Need to login automatically based on windows login
Need to open windows login prompt for another API call
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Apr 13, 2023, 6:00 AM
Hi Sree,
Do refer below link
https://www.c-sharpcorner.com/article/configure-windows-authentication-in-asp-net-core/
https://damienbod.com/2021/04/26/securing-an-asp-net-core-app-and-web-api-using-windows-authentication/
Amit MohantyPosted Apr 13, 2023, 4:01 AM
In your ASP.NET Core project, add the Microsoft.AspNetCore.Authentication.Negotiate NuGet package.
In your Startup.cs file, add the following lines of code to the ConfigureServices method:
This configures the authentication middleware to use Negotiate authentication.
This adds the authentication middleware to the middleware pipeline.
In your controller or action method, you can access the user's Windows identity using the User.Identity property.
To open the Windows login prompt for another API call, you can use the HttpClientHandler class to create a new instance of the HttpClient with Windows authentication enabled. Here's an example: