开发者

ASP.net login control membership provider

Just 2 days ago I got to learn log-in controls and forms authentication in ASP .NET.

Before then I used to create my own database my user table and my own logic for log-in and log-out using sessions and sql server.

The new ways is cool as it allows me to do the work fast than before, but what when I use these log-in and c开发者_如何学Goreate user control a default database ASPNETDB.MDF is saved in App_Data folder.

Since I use my single database for storing everything regarding my site, is it possible to store all the user information in my own database and in my own tables?

I want the power of new controls with the flexibility of my own.


You just have to add a SQL membership provider in your web.config and point it to the right DB, sample extracts below.

<connectionStrings>
    <remove name="LocalSqlServer"/>
    <clear/>
    <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=MYDBNAME;User ID=foo;Password=bar" providerName="System.Data.SqlClient"/>
</connectionStrings>


    <membership>
        <providers>
            <remove name="AspNetSqlMembershipProvider"/>
            <add connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </membership>

Also here a link on how to Create the Membership Schema in SQL Server.


If you want to use your own tables and not the ones that microsoft dictates you will need to use a custom membership provider this article will show you how you can do that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜