ASPNET 5 MVC 6中的远程validation
在aspnet 5中找不到JsonRequestBehavior
我正在尝试实现远程validation演示,似乎Microsoft.AspNet.Mvc不包含JsonRequestBehavior枚举。 但它确实存在于以前版本的MVC中的System.Web.Mvc命名空间中
模型:
public class Person : Entity { [Required] [StringLength(512)] [Remote("IsAllowedName", "Validation", ErrorMessage="This name is not allowed!" )] [Display(Name = "First (and middle) name")] public String FirstMidName { get; set; }
视图:
... ...
控制器:
[HttpGet] public JsonResult IsAllowedName(string FirstMidName) { if (FirstMidName.ToLower() == "oleg") { return Json(false, JsonRequestBehavior.AllowGet); } return Json(true); }
终端输出:
MacBook-Air-Anton:labefmvc antonprudkoglyad$ dnu build ... /Users/antonprudkoglyad/Projects/LabEFMVC/LabEFMVC/Controllers/ ValidationController.cs(20,24): DNXCore,Version=v5.0 error CS0103: The name 'JsonRequestBehavior' does not exist in the current context Build failed.
在ASP.NET Core RC1中,[Remote]属性位于Microsoft.AspNet.Mvc命名空间中。 在ASP.NET Core RC2中,我相信[Remote]属性位于Microsoft.AspNetCore.Mvc命名空间中。
using Microsoft.AspNet.Mvc; [Remote("IsAllowedName", "Validation", ErrorMessage="This name is not allowed!" )]
- asp.net core从构建中排除文件
- 如何从Visual Studio Team Services运行ASP.NET核心entity framework迁移
- 找不到ASP.NET 5.0中的HttpClient?
- ASP.NET Core 2.0 JWTvalidation因“用户授权失败:(null)”错误而失败
- 如何对数据库中的用户使用Windows身份validation
- 我应该如何将一个DbContext实例注入IHostedService?
- 在ASP.NET Core 1.0中引用库(vNext)
- 在web api控制器中使用async / await或task(.net core)
- 实体类型上的导航尚未添加到模型中,或被忽略,或者实体类型被忽略