【发布时间】:2011-03-22 22:26:53
【问题描述】:
我需要在网上发布一个演示网站。我需要确保访问该网站的安全。
使用 SQL Server 作为成员资格提供程序的实时站点。但是,对于演示站点,我只能发布到一个简单的 Web 主机,并且无法访问 SQL Server。
我只需要一个用户,他们不需要更改密码等选项。因此,我认为最简单的方法是使用 web.config 中的成员。我创建如下:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<authentication mode="Forms">
<forms name="ProjectApple" loginUrl="~Login.aspx">
<credentials passwordFormat="Clear">
<user name="lawyer" password="Super12."/>
</credentials>
</forms>
</authentication>
<compilation debug="true"/>
</system.web>
</configuration>
当我可以让它工作时,我将使用 SHA1 哈希。问题是,当我输入了无效密码时,它会识别出来。但是,当我输入正确的密码时,我得到以下信息:
Cannot open user default database. Login failed.
Login failed for user 'RB-T510\Rob'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'RB-T510\Rob'.
我不知道它为什么要寻找 SQL?有人可以帮忙吗?
我正在使用 VS2010 和 .Net 3.5
非常感谢,
罗伯
【问题讨论】:
-
有没有可能是登录成功了,但是下一步(无论打开什么页面)都在尝试执行sql?你能发布其余的 web.config 吗?
-
您的演示配置中是否还有对成员资格提供程序的引用?
-
我会发布整个配置文件和整个堆栈跟踪。
-
如果你想编写自己的使用 XML 文件作为数据源的 MembershipProvider 不会太麻烦。您可以在 XML 文件中添加用户名和密码字段,只需覆盖自定义 MembershipProvider 的 ValidateUser(username, password) 方法。编写自己的 MembershipProvider 不会太难,而且它的好处是您将来也可以重用它。
标签: .net asp.net security authentication