Monday, March 3, 2014

Make Email address unique in create User Wizard ASP.NET

in createuserwizard the userid is unique by default

But in some cases we want to make both user id and email address unique so that a single user don't create multiple account.

we have 2 options

First option is that we can either edit the aspnet membership database and make userId and email as composite key which is not easy

2nd option is to this membership rule in web.config of our project

I will be using option number 2 for this tutorial

add the following taf in your web.config replace the name of connectionStringName as per your requirement

    <membership defaultProvider="CustomizedMembershipProvider">
      <providers>
        <add name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1"/>
      </providers>
    </membership>


I hope it was informative for you and I would like to Thank you for reading.

No comments:

Post a Comment