no

How to setup Membership and Role Provider in web.config

Often I would create a new project and need to tie up the application in aspnet database. And yet I often forgot how to setup the connection...

Often I would create a new project and need to tie up the application in aspnet database. And yet I often forgot how to setup the connection string. So I'm logging them here:

Find the end of the system.web tag: </system.web>
<membership defaultProvider="SQLMembershipProvider">
      <providers>
        <add connectionStringName="aspnetdb" applicationName="applicationName" enablePasswordRetrieval="True" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordFormat="Clear" name="SQLMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="SqlRoleManager">
      <providers>
        <add connectionStringName="aspnetdb" applicationName="applicationName" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
      </providers>
    </roleManager>
Also you need to define the connection string in <connectionStrings>.

<add name="aspnetdb" connectionString="Data Source=Server;Initial Catalog=Database;Persist Security Info=True;User ID=usr;Password=pwd;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>

Note: applicationName, is the entry in the aspnet_Applications table.

I guess you can figure out what the other parameter means.

Related

.net 4302409240718378640

Post a Comment

item