日期:2014-05-20  浏览次数:20832 次

mvc model远程Remote验证碰到的问题
model:
 [Remote("CheckUserNameExists", "Category", ErrorMessage = "名字已存在")] 
        public override string Name
        {
            get
            {
                return base.Name;
            }
            set
            {
                base.Name = value;
            }
        }
controller:
 [HttpGet]
        public ActionResult CheckUserNameExists()
        {
            string name = Request["name"];
            string id = Request["id"] as string;//添加的时候没有id
            return Json(string.IsNullOrEmpty(id) ? !new BackendDBContext().Categories.Any(o => o.Name == name) : !new BackendDBContext().Categories.Any(o => o.Name==name&&o.ID != Convert.ToInt32(id)), JsonRequestBehavior.AllowGet);

        } 
这样设计如果在添加的时候没有问题,但是在编辑的时候我想把需要编辑的model.id传进去、怎么传到验证的方法中去啊?有没有办法请各位高人指教一下....
------解决方案--------------------
没人回答啊怎么