1
Answer

Regular expression exception

Aijaz Ali

Aijaz Ali

8y
245
1

Login Action Method:

public ActionResult Login(Login loginForm, string returnUrl)        {            
if (!ModelState.IsValid) return View("Login");           
var Password = Md5Hash.Encrypt(loginForm.Password);              
var user = (from users in _dbContextModel.user_login where ((users.login_id == loginForm.Login_id) && (users.password == Password))                        select users).FirstOrDefault();              if (user != null)            {                UserLogin userLogin = user;
userLogin.last_login = DateTime.Now;                 // userLogin.password = user.password;                 _dbContextModel.Entry(userLogin).State = EntityState.Modified;                _dbContextModel.SaveChanges();

 Model Class:

 [RegularExpression(@"^(?=*[A-Z])(?=*[a-z])(?=*[0-9])[A-Za-z0-9]{8,}$", ErrorMessage = "invalid")] [Required(ErrorMessage = "Required")] [StringLength(65)] [Display(Name = "Password")] // [RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$", ErrorMessage = "Password contains invalid characters")] //[DataType(DataType.Password)] public string password { get; set; }

When i am using above regular expression, i am facing the following run-time exception why? please give me solution. I am using linq, E.F6 and MVC5 using VS015 and .net framework 4.5.


Answers (1)