看一下运行的效果
当用户名为a密码为b时运行正确
当什么都不填时运行错误
HomeController的代码:
public ActionResult Index() { return View(); } [AcceptVerbs(HttpVerbs.Get)] public JsonResult JuBushuaxin(string name, string pass) { if (name != "a" || pass != "b") { var data = "false"; return Json(data, JsonRequestBehavior.AllowGet); } else { var data = "success"; return Json(data, JsonRequestBehavior.AllowGet); } }
index.cshtml的代码
@{ ViewBag.Title = "Index";}Index
用户名:
密码:
希望对大家有所帮助