MVC 远程验证不调用函数或工作

MVC Remote Validation Not calling function or working

MVC 远程验证不工作,我是 MVC 的新手,感谢任何帮助:

网络配置:

  <appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

控制器:

   [AllowAnonymous]
    public JsonResult CheckAccount(string client_id)
    {
        var user = db.LGC_InboundData_c.Where(x => x.client_id == 
         client_id.Trim());
        return !user.Any() ?
           Json(true, JsonRequestBehavior.AllowGet) :
           Json(string.Format("{0} is already exists."),
               JsonRequestBehavior.AllowGet);
    }

型号Class:

[Remote("CheckAccount", "Home", ErrorMessage = "Account already exists!")]
        public string client_id { get; set; }

查看:

    <div class="col-xs-3">
        @Html.LabelFor(model => model.client_id, htmlAttributes: new { @class = "col-xs-10" })
        <div class="col-md-12">
            @Html.EditorFor(model => model.client_id, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.client_id, "", new { @class = "text-danger" })
        </div>
    </div>

我不知道为什么它不起作用。项目未调用 CheckAccount() 函数。我在我的视图中添加了脚本,但收到此错误消息:

您只包含了视图的一部分,因此我唯一的建议是确保以下脚本包含在您的 View/Layout 中:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

众所周知:HtmlHelper.UnobtrusiveJavaScriptEnabled 已设置为 false。

语法正确。

@Html.AntiForgeryToken()
    HtmlHelper.UnobtrusiveJavaScriptEnabled = true;