Remote validation, value not getting to validation controller

I am trying MVC3 remote validation for the first time. i using it for the classic 'is that user name taken' scenario, and i am failing. I have checked the ajax info in chrome developer and it looks like it sending the value, but at my validation controller, the string is null. From the ajax header (in the google developer): UserData.login:jon the validation controller: public class ValidationController : Controller { // // GET: /Validation/ public JsonResult IsUsernameAvailable(string login) { var repo = new Repository(); bool IsNameInUse = repo.CheckUserName(login); if (IsNameInUse == true) { return Json("The Username has been taken, please try another", JsonRequestBehavior.AllowGet); } return Json(true, JsonRequestBehavior.AllowGet); } } the 'CheckUserName' method: public bool CheckUserName(string Username) { var existingUser = (from u in db.useraccount where u.login.Equals(Username) select u).SingleOrDefault(); if (existingUser == null) { return false; } else { return true; } } and the user model has the Remote attribute on it: [Remote("IsUserNameAvailable", "Validation")] [Display(Name = "Choose a Login Name")] [StringLength(40)] [Required] public string login { get; set; } i have read some stuff about manually binding in the validation controller, but the examples I use to build this did not mention anything about that, so i am assuming manual binding would just be a patch to something I have done wrong. Let me know if you need any other data.

以上就是Remote validation, value not getting to validation controller的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JSON 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏