如何使用 Windows 身份验证和 IIS 配置 Blazor

时间:2021-06-09 19:18:08

标签: iis blazor

在将 IIS 连接到 Blazor 应用程序和 Windows 身份验证后,我遇到了问题。我已经完成了 this guide 中的步骤,但是,每次我访问该站点时,都会出现一个 chrome 对话框,要求我输入用户名和密码。我的理解是 IIS 应该处理我的 Windows 凭据并将其转发到站点。

预期结果

enter image description here

实际结果

enter image description here

我看到 IISExpress 将作为我的本地域用户运行该网站,这工作得很好,应用程序让我进入。当我从 IIS 运行站点时(当它使用 apppool 用户时)是我遇到的问题。我需要能够以我的用户身份进行身份验证,而无需更改运行 Apppool 的用户。

项目的一些信息

launchSettings.json

{    
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    "iis": {
      "applicationUrl": "https://customersupport.dev.local",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:13394",
      "sslPort": 44318
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Shelby.CustomerSupport": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": "true",
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    },
    "IIS": {
      "commandName": "IIS"
    }
  }
}

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="false" />
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="bin\Debug\net5.0\Shelby.CustomerSupport.exe" arguments="" stdoutLogEnabled="false" hostingModel="InProcess">
        <environmentVariables>
          <environmentVariable name="ASPNETCORE_HTTPS_PORT" value="443" />
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>    

我在这里遗漏了什么?

0 个答案:

没有答案