public ActionResult isExist(string Name) { // 限定同網站的Ajax專用 if (!Request.IsAjaxRequest()) { ModelState.AddModelError("", "非 ajax 呼叫"); //throw new Exception("非 ajax 呼叫"); } using (tblScheduleRepository rep = new tblScheduleRepository()) { bool isExist = rep.isExist(Name); return(Json(new { Exist = isExist })); } }