ASP.NET Core 禁用 Windows 身份验证

iro*_*ain 1 asp.net-core-mvc asp.net-core

我有 .NET Core MVC Web 应用程序,在创建过程中我设置了 Windows 身份验证。现在我想禁用 Windows 身份验证并启用匿名身份验证(我有自己的身份验证机制)。这是我在配置文件中设置的内容

.vs\config\applicationhost.config

  <security>
    <authentication>
      <anonymousAuthentication enabled="true" />
      <windowsAuthentication enabled="false" />
    </authentication>
  </security>
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我重新打开解决方案并运行它时,配置更改为:

  <security>
    <authentication>
      <anonymousAuthentication enabled="false" />
      <windowsAuthentication enabled="true" />
    </authentication>
  </security>
Run Code Online (Sandbox Code Playgroud)

有什么可能改变配置,我应该怎么做才能防止这种变化?

Joz*_*zso 5

该文件由 Visual Studio 管理并且正在重新生成。

要禁用 Windows 身份验证,您必须将项目设置更改为 Visual Studio。此设置存储在launchSettings.json文件中,当 ASP.NET Core 托管在 IIS Express 中时,Visual Studio 会为 IIS Express 进程生成applicationhost.config

有关此配置的详细信息,请访问:https : //docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-2.2