The core of the Asp.Net MVC application is Windows Authentication in IIS

My web application Myvp.net Core mvc requires Windows authentication. In development, on IIS Express, everything works fine thanks to this setting

launchSettings.json

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

When deployed to IIS, I get a blank page. A request to my site will receive an error code 500.

I tried adding this configuration to Startup.cs as described here , without success.

  services.Configure<IISOptions>(options => { options.ForwardWindowsAuthentication = true; }); 

When I look at the authentication settings directly in IIS, Windows authentication is activated.

I found a post about a package called Microsoft.AspNetCore.Server.WebListener , others about implementing custom middleware. I can not imagine that this basic function requires a lot of effort to work. Did I miss something?

+8
iis asp.net-core windows-authentication
source share
2 answers

launchSettings.json file is used only by VS. When you publish your application (or launch without VS), launchSettings.json not used. When you start IIS / IISExpress, you just need to make sure your web.config has the correct settings. In your case, the forwardWindowsAuthToken attribute in the web.config file is missing or set to false . It must be set to true for Windows authentication. An example web.config before publishing will look like this:

 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/> </system.webServer> </configuration> 
+12
source share

You need to check web.config in the project directory. These settings helped me.

 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/> <security> <authentication> <anonymousAuthentication enabled="false" /> <windowsAuthentication enabled="true" /> </authentication> </security> </system.webServer> </configuration> 
+1
source share

All Articles