Why doesn't my visual studio asp.net core web application recognise my windows account when running the project

20 Views Asked by At

I have created an ASP.Net core (net 8) web application using visual studio 2022.

I have set up windows authentication and authorisation to check if users exist in an AD group and log them in without having to submit credentials.

When deployed to the web server it works as expected however when I run the application locally in Visual Studio it prompts me to enter my Windows account details.

Does anyone know why this might be?

Thanks

1

There are 1 best solutions below

0
Md Farid Uddin Kiron On

I have created an ASP.Net core (net 8) web application using visual studio 2022.

I have set up windows authentication and authorisation to check if users exist in an AD group and log them in without having to submit credentials.

Well, its hard to infer how did you configured your windows authentication, as you haven't shared with us and that's really important to check.

However, even if you set in AD group but if within your project launchSettings.json doesn't allowed "windowsAuthentication": true you might encounter that issue. So please double check that.

Within your launchSettings.json, you should have following configuration:

"iisSettings": {
  "windowsAuthentication": true,
  "anonymousAuthentication": false,
  "iisExpress": {
    "applicationUrl": "http://localhost:3067",
    "sslPort": 44358
  }
}

enter image description here

Beside that, you might need to check your NegotiateDefaults.AuthenticationScheme configuration because this is also prerequisite for windows authentication.

Note: Please make sure you have enabled windowsAuthentication to true. In addition, please refer to this official document.