Hari Krishna Gaddipati
Hari Krishna Gaddipati

Reputation: 305

windows authentication in aspnet core app while debugging

I am trying to develop an application that uses AD for determining user access. I have implemented the windows authentication and it works when I deploy the app to IIS, but I want to use it while development time for debugging purposes. I have already configured the launchsettings.json file to have below.

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

Why am I not able to get this working. Is there something else that I am missing?

Upvotes: 0

Views: 743

Answers (2)

Hari Krishna Gaddipati
Hari Krishna Gaddipati

Reputation: 305

Right-click on the project and in the debug settings, changed the launch options to IIS. After that I got an error saying dotnet.exe not found. That error lead me to Unable to start process dotnet.exe, which says in IIS, web.config files are useless for aspnetcore projects. I then deleted the web.config file and it worked. I was able to get the user details into the IHttpContextAccessor.

Upvotes: 0

Stefan Steiger
Stefan Steiger

Reputation: 82136

You said IIS-Express - do you have Web.config ?

<system.webServer>
    […]
    <security>
      <authentication>
        <anonymousAuthentication enabled="false"/>
        <windowsAuthentication enabled="true"/>
      </authentication>
    </security>
  </system.webServer>

Upvotes: 1

Related Questions