Using Forms Authentication without .Net providers

China☆狼群 提交于 2019-12-24 14:52:38

问题


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'.

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?


回答1:


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



回答2:


Try this:

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


来源:https://stackoverflow.com/questions/2077858/using-forms-authentication-without-net-providers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!