【问题标题】:Turn off / Disable windows authentication for asp.net-mvc关闭/禁用 asp.net-mvc 的 Windows 身份验证
【发布时间】:2014-11-13 14:04:57
【问题描述】:

我创建了一个新的 asp.net-mvc 项目,在安装过程中我选择使用 Windows 身份验证。

现在我喜欢将其关闭(至少暂时关闭)。

我把 web.config 改成了这个

 <authentication mode="None" />

但这确实改变了一切。它仍然会提示我。我正在使用 IIS Express。

更新:我的意思是在使用 Firefox 时它仍然会提示我。 Internet Explorer 将继续运行并且不显示我的域用户名

【问题讨论】:

    标签: asp.net-mvc-5 windows-authentication


    【解决方案1】:

    1.) 关闭 VS

    2.) 删除解决方案旁边的 .vs/config.vs 文件夹。 IIS Express 重新生成config/applicationhost.config 文件。更改此文件无济于事 - 它会重新生成

    3.) 编辑&lt;project&gt;.csproj.user 文件。那里换行

    <IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
    <IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
    

    <IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
    <IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
    

    4.) 编辑和更改 web.config 改变

    <authentication mode="Windows" />
    

    <authentication mode="None" />
    

    或注释整个身份验证 XML 元素。

    【讨论】:

      【解决方案2】:

      Web 配置应该覆盖 IIS express 配置,但在这种情况下似乎没有。您可以尝试在 IIS 级别也将其关闭。

      你可以到这个目录\IISExpress\config\applicationhost.config打开这个文件并设置&lt;windowsAuthentication enabled="false" /&gt;

      【讨论】:

      • 我在添加了您建议的行的那个文件夹中找到了一个名为 Administration.config 的文件。但 Firefox 仍然提示输入凭据
      • 不是管理配置。它应该是 applicationhost.config。你能在你的 IISExpress 目录下搜索这个文件并以管理员身份编辑然后重新启动 IIS。
      • 澄清一下,IE 不会提示您登录。对吗?
      • 我怀疑 IE 正在使用模拟,它也适用于 IE。当我打开它时,它会显示我的用户名,当我关闭它时,它不会显示我的用户名。所以是的,我相信问题只出在 Firefox 上
      • 可能是一个很长的镜头,但您尝试过使用 Chrome 吗?可能是 Firefox 缓存。私密/隐身会话也会发生这种情况吗?
      【解决方案3】:

      我发现通过使用以下文档在网络配置中这是可能的:

      https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.1&tabs=visual-studio

      web.config 的相关块是:

        <security>
          <authentication>
            <windowsAuthentication enabled="false" />
          </authentication>
        </security>
      

      【讨论】:

        【解决方案4】:

        您应该卸载项目,编辑项目 .csproj 文件并更改行:

        <IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
        <IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
        

        然后,您应该删除项目的 .csproj.user 文件,并删除解决方案的 de .vs 目录。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-01-31
          • 1970-01-01
          • 1970-01-01
          • 2010-11-27
          相关资源
          最近更新 更多