开发者

Using Forms Authentication without .Net providers

I want to protect a s开发者_高级运维ection 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'.

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.

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


Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜