It's easy to use SimpleMembership in ASP.net MVC 4 to require users to enter a unique username - or swap that out for a unique email.
However - whats the easiest way to require both a unique username AND email when registering?
It's easy to use SimpleMembership in ASP.net MVC 4 to require users to enter a unique username - or swap that out for a unique email.
However - whats the easiest way to require both a unique username AND email when registering?
Add unique constraint to your datbabase will be the easiest way. You can call SQL script in database initialization.
One more thing. Before registering you can get users by email and by username and check this logic yourself. But for this you will have to query database yourself, because SimpleMembership does not have such feature.
UPDATE If you are using .NET 4.5 you can use: http://msdn.microsoft.com/pl-pl/library/system.web.security.membershipprovider.requiresuniqueemail.aspx
So your web.config will look like
<membership>
<providers>
<add name="SimpleMembershipProvider"
type="whatever your assembly name is"
...
requiresUniqueEmail="true"/>