Tuesday 24 December 2013

ASP Membership


To add asp membership DB to your DB

  1. Go to .net framework version on your windows directory (C:\Windows\Microsoft.NET\Framework64\v4.0.30319)
  2. Double click on (aspnet_regsql.exe), choose (Configure SQL for application services) and press next, type the server name and select your DB or type new DB name. finish
  3. Copy the following code and past it in your site web.config file 


<configuration>
  <connectionStrings>
    <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=ApplicationManagmentDB;" />
  </connectionStrings>
  <system.web>
    <authentication mode="Forms" >
    
    </authentication>
    <authorization>
      <deny users="?" />
      <allow roles="Administrators" />
      <deny users="*" />
    </authorization>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="SqlServices"
          enablePasswordRetrieval="false"
          enablePasswordReset="false"
          requiresQuestionAndAnswer="false"
          passwordFormat="Hashed"
          applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="SqlProvider"
      enabled="true"
      cacheRolesInCookie="true"
      cookieName=".ASPROLES"
      cookieTimeout="30"
      cookiePath="/"
      cookieRequireSSL="true"
      cookieSlidingExpiration="true"
      cookieProtection="All" >
      <providers>
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlRoleProvider"
          connectionStringName="SqlServices"
          applicationName="/" />
      </providers>
    </roleManager>
  </system.web>
</configuration>