Q:

ASP.NET MVC DataAnnotation - Convert to Lowercase

I am having a bit of a problem with login/register authentication on a site in regards to case scheme. 
First, I started out by just having the regular expression for the input fields only accept lowercase. Seemed like the smartest thing to do. But that backfired horribly. Basically put, even if I put in the text You must use only lowercase letters, people don't read it, get frustrated, and then just don't bother to register.
So then, to remedy this, I fixed it so that the regular expression could take both upper and lowercase values. When I stored the email addresses in the database, I just converted them to lowercase. Everyone seemed happy for about 8 seconds.
However I am finding myself having to do this in multiple places, now. And it is getting obnoxious. I was wondering if there was a way to make a DataAnnotation for my ViewModel, like ..
class LoginViewModel {
   [ConvertLowercase]
   public string Email { get; set; }

   /// ... other view model properties
}

That would always ensure that that result turned lowercase before it hits my controller, thus bottlenecking the entire operation at the ViewModel and taking it away from the redundant repetition of putting the logic in every query, request, and lookup. 
Any suggestions? I've looked into building my own custom data annotations but I've only managed to understand it as far as validation goes, not actually manipulating data.

A:

IMHO DataAnnotations can't and shouldn't change the data. This kind of logic should go either in custom model binder or in an action filter. Or, probably even better, in the data repository before you save the data to the datastore.
Also, you don't always have to have everything the right case, it can become a pain to ensure that, rather than that try to use overloads of string Compare, Equals function (or Linq functions) that take StringComparison or StringComparer and provide OrdinalIgnoreCase to it.

A:

here is one option: (creating readonly property which is to be passed to your controller/business layer)
class LoginViewModel {

     public string Email { get; set; }

     public string LowerCaseEmail  
     {                                    //This is a read only property.
          get { 
                return Eamil.ToLower();
              }
     }

     /// ... other view model properties
  }

