自定義安全ASP.Net的安全基礎--引

You need to run aspnet_regiis.exe to setup the tables/stored procedures in your database for membership. Then you need to create a connection string to your database in your web config file.

 <connectionStrings>
  <add name="MyConn" connectionString="Data Source=COMPUTERNAME/SQLExoress;Initial Catalog=MyDB;Persist Security Info=True;User ID=MYUSERNAME;Password=MYPASSWD"
   providerName="System.Data.SqlClient" />
 </connectionStrings>

After that you can open the  aspnet_Applications table in SQL Mgmt studio express and add the application, you need an  application name /MYAPP a lowered application name /myapp and optionally a description.

 After that you can add the membership provider code and  role provider code in your web.config

<membership defaultProvider="CustomizedProvider">
            <providers>
                <add name="CustomizedProvider"
                    type="System.Web.Security.SqlMembershipProvider"
                    connectionStringName="MyConn"
                    applicationName="/MYAPP"
                    minRequiredPasswordLength="5"
                    requiresQuestionAndAnswer="false"
                    minRequiredNonalphanumericCharacters="0"/>
            </providers>
        </membership>
       
        <roleManager enabled="true" defaultProvider="CustomizedRoleProvider" cacheRolesInCookie="true">
            <providers>
                <add name="CustomizedRoleProvider"
                    type="System.Web.Security.SqlRoleProvider"
                    connectionStringName="MyConn"
                    applicationName="/MYAPP"/>
            </providers>
        </roleManager>

Then you should be able to use the Configuration Application

發佈了142 篇原創文章 · 獲贊 3 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章