Relax Password Constraints

Here is the code to put into the Web.config file to relax password constraints (page 150 in the English edition of the book). It is all case-sensitive and must be typed perfectly in order to work. The code is just an example, not a requirement or recommendation. It eases the password constraints so that the minumum password length is 5 characters, and no special punctuation characters are required. For example, abcde would be a valid password. You can configure your password constraints as you see fit and as appropriate for your Web site.

Copy-and-paste the entire chunk of code below to your site's Web.config file, pasting it just above the closing </system.web> tag.

<!-- Relax password constraints -->
        <membership>
            <providers>
                <remove name="AspNetSqlMembershipProvider"/>
                <add name="AspNetSqlMembershipProvider"
                    type="System.Web.Security.SqlMembershipProvider"
                    connectionStringName="LocalSqlServer"
                    minRequiredPasswordLength="5"
                    minRequiredNonalphanumericCharacters="0"
                    passwordStrengthRegularExpression=""
                 />                
            </providers>
        </membership>
<!-- End relax password constraints -->

Once pasted in, the code should automatically be color-coded as below, and you should see the closing </system.web> under the code in your Web.config file. That </system.web> should already be in your Web.config file. It's not something you need to type or paste in yourself.

Visual Web Developer Relax Password Constraints code in Web.config

The comments (shown in green above) are optional. You don't have to include those if you don't want to.

It isn't necessary to write and tell me about strong passwords. I get that already. This is an example for developers who want to give their users easier passwords where there's no particularly valuable or personally identifiable information stored in user accounts.

Home