0
我想在我的應用程序中使用遠程驗證來檢查已存在的記錄。mvc遠程驗證不起作用
這裏:
[Required(ErrorMessage = "*")]
public Nullable<long> fk_Store_ID { get; set; }
[System.Web.Mvc.Remote("doesGround", "User", HttpMethod = "POST", ErrorMessage = "Ground Level is already exists for this store.", AdditionalFields = "fk_Store_ID")]
[DefaultValue(false)]
public bool MembershipGroundLevel { get; set; }
和我的控制器操作:
[HttpPost]
public JsonResult doesGround(bool MembershipGroundLevel, long? fk_Store_ID)
{
Int64 store_id = Convert.ToInt64(fk_Store_ID);
var count = db.tbl_Membership
.Where(o => o.fk_Store_ID == store_id && o.MembershipGroundLevel == true && o.isVisible == true).Count();
return count >= 1 ? Json(false, JsonRequestBehavior.AllowGet) : Json(true, JsonRequestBehavior.AllowGet);
}
在這裏我得到了兩個NULL值。如果我將數據類型分別更改爲bool和long。我得到的內部服務器的500錯誤
你能告訴我們爲'fk_Store_ID'和'MembershipGroundLevel'輸入生成的html嗎? – tutok