Jquery 客户端未生成数据val和所需数据val

Jquery 客户端未生成数据val和所需数据val,jquery,validation,asp.net-core,asp.net-core-mvc,Jquery,Validation,Asp.net Core,Asp.net Core Mvc,使用ASP.NET Core MVC,我试图使用引导表单组和表单控件以及带有注释的模型来呈现客户端验证,但它不起作用。但是,如果我使用编辑器进行验证,验证工作就可以了。对于我正在使用的脚本: "jquery": "~3.1.1", "jquery-validation": "~1.15.1", "jquery-validation-unobtrusive": "~3.2.6" 我的模型看起来像这样 public class LoginViewModel { [Required]

使用ASP.NET Core MVC,我试图使用引导表单组和表单控件以及带有注释的模型来呈现客户端验证,但它不起作用。但是,如果我使用编辑器进行验证,验证工作就可以了。对于我正在使用的脚本:

"jquery": "~3.1.1",
"jquery-validation": "~1.15.1",
"jquery-validation-unobtrusive": "~3.2.6"
我的模型看起来像这样

public class LoginViewModel
{
    [Required]
    public string Username { get; set; }
    [Required]
    public string Password { get; set; }
    [Required]
    public string Mystring { get; set; }
}
我的看法是:

@model PrioritizedListUI.Models.LoginViewModel
@{
ViewBag.Title=“登录”;
}
登录
@LabelFor(model=>model.Mystring,htmlAttributes:new{@class=“controllabel col-md-2”})
@EditorFor(model=>model.Mystring,new{htmlAttributes=new{@class=“form control”}})
@Html.ValidationMessageFor(model=>model.Mystring,“,new{@class=“text danger”})

您是否在_ViewImports.cshtml中添加了标记帮助程序?否则,在views文件夹下创建一个razor HTML文件,并将其命名为_ViewImports.cshtml。并添加以下代码

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper "*, <YOUR_WEB_APP_NAME>"
@addTagHelper*,Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper“*,”

然后重试。

请不要使用术语MVC6。不再有MVC6了,只有ASP.NET核心MVC(1.0和1.1)实现了它。非常感谢你!