asp.net-mvc - 将远程属性添加到 asp.net 核心时出错
问题描述
当我将[Remote()]
属性添加到类属性时,会抛出以下异常:
TypeLoadException:无法从程序集“System.Web,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a”加载类型“System.Web.Routing.RouteValueDictionary”
using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace Entities
{
[Serializable]
public class EmployeeEntity
{
public int Id { get; set; }
[Required(ErrorMessage = "Required")]
[MaxLength(20)]
[RegularExpression(@"^\S*$", ErrorMessage = "No white space allowed")]
[Remote("IsUserNameAvailable", "Employee",HttpMethod ="GET", ErrorMessage = "EmailId already exists in database.")]
解决方案
已解决 - 在我安装 Microsoft.AspNetCoreCore.Routing 之后。问题是在 asp 核心项目中使用 System.Web.Mvc
推荐阅读
- php - 使用 url 行从 txt 获取文件大小
- npm - 为什么 npm 将 cmd 行标志直接传递给我的脚本?
- python - 将 UT(通用时间)转换为 JD(儒略日期)(天文学)
- ios - 具有旋转闪烁动画的自定义指示器,如 UIActivityIndicatorView
- ios - 只显示我的浮点数到某个小数位 - Swift
- python - 从另一个整数列表中按索引从列表中删除元素
- javascript - 量角器:自动 .sendKeys() 将我的文本转换为大写字母
- c# - 拖放事件后关联项目列表
- capl - 如何在 CAPL 的诊断请求中设置 DTC 状态位?
- python - 如何在 np.array 旁边保存整数