使用窗体身份验证,而不.NET提供 [英] Using Forms Authentication without .Net providers

查看:117
本文介绍了使用窗体身份验证,而不.NET提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用窗体身份验证的用户名和密码由我在web.config中定义,以保护我的网站的一部分。当我尝试登录我得到下面的信息。

I want to protect a section of my website using forms authentication with the username and password as defined by me in the web.config. When I attempt to login I get the message below.

Server Error in '/' Application.

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

我猜这种情况正在发生,因为它试图使用成员表由LocalSqlServer连接字符串的定义。 我不希望使用会员功能后,如何配置我的web应用程序做到这一点?

I'm guessing this is happening because it's attempting to use the Membership tables as defined by the LocalSqlServer connection string. I don't want to use the Membership features, how do I configure my web app to do that?

我需要写的身份验证功能自己的内置登录控制?

Will I need to write the Authenticate function myself for the in-built Login control?

推荐答案

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

The problem isn't with your config file, it's with the Login control.

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

The Login control uses the default Membership Provider that is defined in the machine.config. (It's a SqlMembershipProvider that points to a SQL Express database).

您不希望在所有使用默认的成员资格提供程序。简单地创建自​​己的登录页面,并使用以下服务器端逻辑验证凭据并记录用户到该网站:

You don't want to use the default Membership Provider at all. Simply create your own login page and use the following server-side logic to validate the credentials and log the user into the site:

    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.";

这篇关于使用窗体身份验证,而不.NET提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆