配置MemberShip
(1)打开Visual Studio 2012 Command Prompt,输入aspnet_regsql.exe,弹出ASP.NET SQL Server Setup Wizard...
然后根据提示建立数据库
(2)配置网站的Web.config文件
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="MemberRoleConn" connectionString="Data Source=(local)\sqlexpress;Initial Catalog=MyTestDB;Integrated Security=True" />
</connectionStrings>
<system.web>
<membership defaultProvider="SqlMemProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="SqlMemProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MemberRoleConn" applicationName="SduCourseFtp" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false"
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="true" passwordFormat="Hashed" />
</providers>
</membership>
<roleManager defaultProvider="SqlRProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" >
<providers>
<add name="SqlRProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MemberRoleConn" applicationName="SduCourseFtp" />
</providers>
</roleManager>
</system.web>
</configuration>
(3)在vs2012上面项目,asp.net配置菜单中打开ASP.NET Web Site Administration Tool对Users、Roles以及Access Rules进行设置
到此已完成对Membership以及Roles的配置,可以利用Asp.net自带的登陆控件来进行应用了。
(1)打开Visual Studio 2012 Command Prompt,输入aspnet_regsql.exe,弹出ASP.NET SQL Server Setup Wizard...
然后根据提示建立数据库
(2)配置网站的Web.config文件
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="MemberRoleConn" connectionString="Data Source=(local)\sqlexpress;Initial Catalog=MyTestDB;Integrated Security=True" />
</connectionStrings>
<system.web>
<membership defaultProvider="SqlMemProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="SqlMemProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MemberRoleConn" applicationName="SduCourseFtp" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false"
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="true" passwordFormat="Hashed" />
</providers>
</membership>
<roleManager defaultProvider="SqlRProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" >
<providers>
<add name="SqlRProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MemberRoleConn" applicationName="SduCourseFtp" />
</providers>
</roleManager>
</system.web>
</configuration>
(3)在vs2012上面项目,asp.net配置菜单中打开ASP.NET Web Site Administration Tool对Users、Roles以及Access Rules进行设置
到此已完成对Membership以及Roles的配置,可以利用Asp.net自带的登陆控件来进行应用了。