2010-01-16 51 views
1

我想用我在web.config中定义的用户名和密码使用表单身份验证来保护我的网站的一部分。当我尝试登录时,我会看到下面的消息。使用没有.Net提供程序的Forms身份验证

Server Error in '/' Application. 

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'. 

我猜这是因为它试图使用由LocalSqlServer连接字符串定义的Membership表。 我不想使用会员功能,我该如何配置我的web应用程序来做到这一点?

我是否需要为内置登录控件自己编写Authenticate函数?

+0

嗨,你已经使用过asp.net SQL Server安装工具吗? http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx – keyboardP 2010-01-16 15:47:45

+0

这正是我不想使用的。让我重新迭代,我不想使用Membership特性。 – 2010-01-17 16:55:02

+0

另一个非常类似的问题与不同的答案:http://stackoverflow.com/questions/1583262/asp-net-authentication-use-credentials-from-web-config-problem – Greg 2010-01-29 16:21:47

回答

1

的问题不在于你的配置文件,它是一个与登录控制。

Login控件使用machine.config中定义的默认成员资格提供程序。 (这是一个指向SQL Express数据库的SqlMembershipProvider)。

您根本不想使用默认的成员资格提供程序。只需创建自己的登录页面,并使用以下服务器端逻辑来验证凭据并将用户登录到该站点:

if(Page.IsValid) 
     if (FormsAuthentication.Authenticate(txtName.Text,txtPassword.Text)) 
      FormsAuthentication.RedirectFromLoginPage(txtName.Text, false); 
     else 
      lblMsg1.Text = "Wrong name or password. Please try again."; 
0

试试这个:

<authentication mode="Forms"> 
    <forms loginUrl="Login.aspx"> 
    <credentials> 
     <user name="Joe" password="Smith" /> 
    </credentials> 
    </forms> 
</authentication> 
+0

我知道这一点,这个设置已经。即使我已经按照您所描述的方式定义了我的配置,但我的应用程序试图访问SQL。 – 2010-01-17 16:53:44

+0

你的.config会员资格条目怎么样? – 2010-01-17 19:21:23

+0

我没有在我的web.config中定义的成员资格条目 – 2010-01-18 03:23:18

相关问题