这是我的User模型类:
public class User
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string FullName { get; set; }
[Required]
[MaxLength(30)]
[Remote("IsUsernameExists", "Home", HttpMethod = "Post")]
public string UserName { get; set; }
[Required]
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$"]
public string Email { get; set; }
[Required]
[StringLength(maximumLength: 18, MinimumLength = 8)]
public string Password { get; set; }
}
这是控制器中的IsUsernameExists方法Home
public JsonResult IsUsernameExists(string UserName)
{
return Json(!db.Users.Any(x => x.Username == UserName), JsonRequestBehavior.AllowGet);
}
但它不起作用。任何进一步的帮助将不胜感激!
开满天机
慕工程0101907
长风秋雁
相关分类