I am developing a site that uses the built in account model / controller that comes with the new MVC site template. I want to be able to only allow people to register if they use one of two specific domains in their email address.
So for example they can register if they use @domain1.co.uk or @domain2.co.uk, but no other domains (for example Gmail, Yahoo etc) can be used.
If anyone could point me in the right direction that would be great.
If using the MVC3 default site, you’ll have a
/Models/AccountModels.csfile. You can add a regular expression there to cause client-side* and server-side validation.You will need to work out the expression that works out best for your requirements.
*client-side validation assumes your view references the jquery.validate script and has
Html.ValidationMessageFor(m => m.Email)and/orHtml.ValidationSummary(), which it should by default.