[英]ASP.net login control membership provider
Just 2 days ago I got to learn log-in controls and forms authentication in ASP .NET. 就在两天前,我还学习了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. 在此之前,我曾经创建自己的数据库,用户表以及使用会话和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 create user control a default database ASPNETDB.MDF is saved in App_Data folder. 新方法很酷,因为它使我能够比以前更快地完成工作,但是当我使用这些登录并创建用户控件时,默认数据库ASPNETDB.MDF保存在App_Data文件夹中。
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. 您只需要在web.config中添加SQL成员资格提供程序 ,然后将其指向正确的数据库即可,以下示例摘录。
<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 . 另外,这里还有一个有关如何在SQL Server中创建成员资格架构的链接。
如果您要使用自己的表,而不是Microsoft指示的表,则需要使用自定义成员资格提供程序, 本文将向您展示如何做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.