不断提示输入凭据
Keeps being prompted for credentials
到目前为止我做了什么:
用这个web.config创建了网站(这只是设置部分,不是整个文件:))
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<add key="autoFormsAuthentication" value="false"/>
<add key="enableSimpleMembership" value="false"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2"/>
<httpRuntime targetFramework="4.6.2"/>
<authentication mode="Windows"></authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
创建了控制器:
[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();
}
}
我通过以下方式获得了凭据:cmd -> whoami
- 我以发布模式将我的 mvc 站点发布到 c:\inetpub\wwwroot\backoffice
在 IIS 中:
我什至在 Intranet 选项中将我的站点添加到本地 Intranet,并且:
它只是一次又一次地提示我输入凭据:
只是想帮助遇到这个问题的人:
我所做的解决问题的方法是:
单击 VS 中的项目。
按 F4 转到属性
将 "Anonymus Authentication" 设置为禁用
在web.config中:
<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();
}
其中 pcName 是您电脑的名称(不是 WORKGROUP!)
这样您就可以控制谁被允许(因为匿名身份验证被禁用)。
希望对大家有所帮助。
罗腾
到目前为止我做了什么:
用这个web.config创建了网站(这只是设置部分,不是整个文件:))
<appSettings> <add key="webpages:Version" value="3.0.0.0"/> <add key="webpages:Enabled" value="false"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> <add key="autoFormsAuthentication" value="false"/> <add key="enableSimpleMembership" value="false"/> </appSettings> <system.web> <compilation debug="true" targetFramework="4.6.2"/> <httpRuntime targetFramework="4.6.2"/> <authentication mode="Windows"></authentication> <authorization> <deny users="?"/> </authorization> </system.web>
创建了控制器:
[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(); } }
我通过以下方式获得了凭据:cmd -> whoami
- 我以发布模式将我的 mvc 站点发布到 c:\inetpub\wwwroot\backoffice
在 IIS 中:
我什至在 Intranet 选项中将我的站点添加到本地 Intranet,并且:
它只是一次又一次地提示我输入凭据:
只是想帮助遇到这个问题的人: 我所做的解决问题的方法是: 单击 VS 中的项目。 按 F4 转到属性 将 "Anonymus Authentication" 设置为禁用
在web.config中:
<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();
}
其中 pcName 是您电脑的名称(不是 WORKGROUP!)
这样您就可以控制谁被允许(因为匿名身份验证被禁用)。
希望对大家有所帮助。 罗腾