Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不断提示输入凭据_C#_Asp.net Mvc_Authentication_Windows Authentication - Fatal编程技术网

C# 不断提示输入凭据

C# 不断提示输入凭据,c#,asp.net-mvc,authentication,windows-authentication,C#,Asp.net Mvc,Authentication,Windows Authentication,到目前为止我所做的: 使用此web.config创建网站(这只是设置部分,而不是整个文件:) 我通过:cmd->whoami获得了我的证书 我以发布模式将我的mvc站点发布到c:\inetpub\wwwroot\backoffice 在IIS中: 我甚至在intranet选项中将我的站点添加到本地intranet,并且: 它只是一次又一次地提示我获取凭据: 为了帮助遇到这个问题的人: 解决问题的方法是: 单击VS中的项目。 按F4键转到属性 将“匿名身份验证”设置为禁用 在web.conf

到目前为止我所做的:

  • 使用此web.config创建网站(这只是设置部分,而不是整个文件:)

  • 我通过:cmd->whoami获得了我的证书

  • 我以发布模式将我的mvc站点发布到c:\inetpub\wwwroot\backoffice
  • 在IIS中:

  • 我甚至在intranet选项中将我的站点添加到本地intranet,并且:

  • 它只是一次又一次地提示我获取凭据:


    为了帮助遇到这个问题的人: 解决问题的方法是: 单击VS中的项目。 按F4键转到属性 将“匿名身份验证”设置为禁用

    在web.config中:

    <authentication mode="Windows"></authentication>
    <authorization>
      <allow users="*" />
    </authorization>
    
    其中pcName是您电脑的名称(不是工作组!)

    通过这种方式,您可以控制谁是被允许的(因为匿名身份验证被禁用)

    希望它能帮助别人。
    Rotem

    因为您在安全设置中指定了提示输入用户名和密码的用户身份验证!如果您只使用
    [Authorize]
    ,它是否有效?这可能是因为你不需要指定电脑名,它无法工作,因为它无法识别用户名。Hi@Kaj的可能重复项,即使我在“internet选项”中设置为“匿名登录”@TAHASULTANTEMURI,它也无法工作。我尝试了那里的建议,但没有成功。
    [Authorize(Users = @"myPcName\myUserName,skynet\Simple")]
    public class AuthenController : Controller
    {
        [Authorize(Users = @"myPcName\myUserName")]
        public ActionResult ForAdministrator()
        {
            return View();
        }
        [Authorize(Users = @"myPcName\Simple")]
        public ActionResult ForUser()
        {
            return View();
        }
    }
    
    <authentication mode="Windows"></authentication>
    <authorization>
      <allow users="*" />
    </authorization>
    
        [Authorize(Users = @"pcName\user")]
        public ActionResult ForAdministrator()
        {
            return View();
        }
    
        // Authorization with windows authentication (user)
        [Authorize(Users = @"pcName\user")]
        public ActionResult ForUser()
        {
            return View();
        }