在mvc 4内部网站点中,当应用程序加载时,如果主页控制器索引操作,您将如何强制用户输入Windows凭据。似乎浏览器正在记住密码。如果是这样,你可以禁用浏览器'从记忆?
我正在使用IIS Express。
我允许禁用匿名身份验证 启用Windows身份验证 Home Controller的Index Action具有Authorize属性。 (现在尝试控制器级别)
我认为强制输入凭证。
我跟着这个 http://www.itorian.com/2013/05/windows-authentication-in-mvc4-with-iis.html
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<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.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<identity impersonate="true" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
控制器
[Authorize]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your app description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
答案 0 :(得分:1)
这是我猜你没有提供<appSettings>
部分:
guide(与您提供的链接相同)表示您应该设置这两个值:
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
这是唯一能让我想到的内容,我发现每个来源autoFormsAuthentication
都会改变。
我发现的另一件事是Microsoft's guide。这是MVC 3,但我不知道有什么重大变化。它比原始教程更长,但它涵盖了所有设置并解释了您需要做的所有事情。
答案 1 :(得分:1)
当您知道提示出现的原因时,您知道如何打开和关闭提示,
http://support.microsoft.com/kb/258063
Internet Explorer必须满足以下条件: 自动验证用户的登录和密码并进行维护 安全:
- Windows集成身份验证,也称为Windows NT 必须在IIS中的网站属性中启用质询/响应。 首先尝试匿名身份验证,然后是Windows 集成身份验证,摘要式身份验证(如果适用),以及 最后是Basic(明文)认证。
- 客户端和Web 服务器必须位于相同的基于Microsoft Windows NT或 基于Microsoft Windows 2000的域或受信任的基于Windows NT或 可以授予用户帐户的基于Windows 2000的域 基于IIS的计算机上的资源权限。
- 用户的浏览器 必须是Internet Explorer。 Internet Explorer是唯一的浏览器 支持Windows集成身份验证(NTCR)。
- Internet Explorer 必须考虑请求的URL在Intranet(本地)上。如果 请求的URL的计算机名称部分包含句点(例如 Internet Explorer, http://www.microsoft.com和10.0.0.1) 假设所请求的地址存在于Internet上,而不是 自动传递任何凭据。没有句号的地址(例如 网络服务器)被认为是在内联网(本地); Internet Explorer自动传递凭据。唯一的例外 是Internet Explorer中Intranet区域中包含的地址。
- Internet Explorer的Intranet区域安全设置必须设置为 仅在Intranet区域中自动登录。这是默认设置 IE浏览器。有关Internet Explorer的其他信息 安全区域,单击下面的文章编号查看文章 Microsoft知识库:
174360如何使用安全区域 Internet Explorer
- 请求网页的用户必须拥有 适当的文件系统(NTFS)对网页的权限以及 网页中引用的所有对象。例如,用户可以 拥有网页的完全控制权限,但会提示输入密码 如果网页引用安全文件夹中的图形。
如果您故意破坏上述任何一种情况,可以触发提示。