【发布时间】:2012-09-14 13:47:31
【问题描述】:
有一个代码盲时刻。
ASP.NET 4.0。
Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="DataViewer" loginUrl="login.aspx">
<credentials passwordFormat="Clear">
<user name="devuser" password="test" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
还有一个登录控件:
<asp:Login ID="login" runat="server" />
如果我输入用户名和密码,然后单击登录,它就会挂起。
如果我中断,我可以在调用堆栈中看到login.AuthenticateUsingMembershipProvider() 正在调用SqlMembershipProvider.ValidateUser()。这个项目根本没有定义或涉及数据库,我也没有指定应该使用SqlMembershipProvider。
所以我的问题是,我应该使用哪个会员提供程序来让 ASP.NET 使用 web.config 的 <credentials> 元素中的用户名和密码?
【问题讨论】:
-
可能是因为默认的成员资格提供程序是 AspNetSqlProvider,它使用 SQL Server 数据库作为其用户存储。
-
我希望这是一个临时解决方案。在 web.config 中维护凭据将变得非常困难,因为每次更改都会重新启动 Web 应用程序。
-
当然。但是它适合手头的场景。我需要为密码永远不会更改的单个用户(曾经)为简单的应用程序提供微不足道的保护。具有更大依赖性的解决方案是不合适的。
标签: asp.net membership-provider