Asp.net 使用时面临错误;“远程”;及;比较;一次注释

Asp.net 使用时面临错误;“远程”;及;比较;一次注释,asp.net,asp.net-mvc,data-annotations,Asp.net,Asp.net Mvc,Data Annotations,我正在使用远程验证来验证用户名是否已被使用,它工作正常。但是现在我需要添加“compare”数据注释来比较password和confirmPassword字段。但它给了我错误,因为缺少装配。当我删除库System.Web.Mvc(用于Remote)时,错误就会消失。 remote和compare之间是否存在冲突,或者我遗漏了什么 using System.Web.Mvc using System.ComponentModel.DataAnnotaion public partial class

我正在使用远程验证来验证用户名是否已被使用,它工作正常。但是现在我需要添加“compare”数据注释来比较
password
confirmPassword
字段。但它给了我错误,因为缺少装配。当我删除库
System.Web.Mvc
(用于
Remote
)时,错误就会消失。
remote
compare
之间是否存在冲突,或者我遗漏了什么

using System.Web.Mvc
using System.ComponentModel.DataAnnotaion

public partial class user
{
    [Remote("CheckExistingUsername","Home",ErrorMessage = "Email already exists!")]
    public string Username{get;set;}
    public string password {get;set;}

    [Compare("password",ErrorMessage="Un Matched")]
    public string confirmPassword {get;set;}
}
这样做,

[CompareAttribute("pass", ErrorMessage = "Unmatched")]

有关比较属性的详细信息,请单击尝试添加与命名空间比较

[System.ComponentModel.DataAnnotations.Compare("pass",ErrorMessage = "unmatched")]

默认情况下,它使用的是可能导致问题的
System.Web.Mvc.CompareAttribute
的比较

您的问题需要包含代码,而不是它的图像。