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!" )]