在aspnet 5中找不到JsonRequestBehavior
我正在尝试实现远程验证演示,似乎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; }
视图:
... <input asp-for="FirstMidName"/> <span asp-validation-for="FirstMidName"></span> ...
控制器:
[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.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。