Friday, January 18, 2013

How to validate an email address by Model DataAnnotations in ASP.NET MVC

[Required]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email address")]
        [RegularExpression(@"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",ErrorMessage="Invalid email address")]
        public string Email { get; set; }

What is the best regular expression for an email address?

^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$

??

http://fightingforalostcause.net/misc/2006/compare-email-regex.php

Adding SignalR to an ASP.Net WebForms Project

http://www.csharpfritz.com/blog/2013/1/10/adding-signalr-to-an-aspnet-webforms-project