Search code examples
c#asp.netweb-configmembership-provider

ASP.Net c# Membership provider <add name> attributes in web.config


I have tried to add attributes to the "add name" section of the membership provider but Intellisenxe does not seem to support them> Some of the attributes I would like to add are:

  1. minReqiredNonalphanumericCharacters
  2. maxInvalidPasswordAttempts
  3. requiresUniqueEmail

Below is the web.config. Thanks in advance.

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />

      <roleManager enabled="true"
                 defaultProvider="CustomizedRoleProvider">
        <providers>
          <add name="CustomizedRoleProvider"
               type="System.Web.Security.SqlRoleProvider"
               connectionStringName="RestaurantDB" />
        </providers>
      </roleManager>

      <membership defaultProvider="CustomizedMembershipProvider">
        <providers>
          <add name="CustomizedMembershipProvider" 
               minRequiredPasswordLength="6" 
               type="System.Web.Security.SqlMembershipProvider"
               connectionStringName="RestaurantDB" />
        </providers>
      </membership>      
    </system.web>

  <appSettings>

  </appSettings>

  <connectionStrings>
    <add name="RestaurantDB" connectionString="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Integrated Security=SSPI;"/>
    <add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>



</configuration>

Solution

  • try this:

    <configuration>
            ...
            <system.web>
                ...
                
                    <membership 
                     defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
                     <providers>
                        <clear/>
                        <add name="SqlProvider"
                            type="System.Web.Security.SqlMembershipProvider"
                            connectionStringName="LocalSqlServer"
                            enablePasswordReset="true"
                            requiresQuestionAndAnswer="false"
                            requiresUniqueEmail="false"
                            maxInvalidPasswordAttempts="5"
                            passwordAttemptWindow="10"
                            passwordFormat="Hashed"
                            minRequiredPasswordLength="7"
                            minRequiredNonAlphanumericCharacters="0"
                            passwordStrengthReqularExpression="0"
                            enablePasswordRetrieval="false"
                            applicationName="/" />
                    </providers>
                </membership>
                ...
            </system.web>
            ...
        </configuration>