我收到以下错误:
Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required
我不知道为什么,我已经阅读了一些关于自定义验证和 ninject 的内容,但我不认为是这样。
我正在创建一个自定义帐户管理系统,管理员可以在其中创建/编辑用户。我正在使用ASP.NET Membership, Role, Profile
. 当您创建一个带有Internet
勾选的新应用程序时,它会创建所有帐户内容。我试图做的只是重用RegisterModel
我的AccountManagement
Area
. 但随后错误开始出现,我没有任何自定义验证提供程序或任何东西。错误/异常也出现在Account
Views
(由 MVC 模板创建的)中。
错误发生在视图的这一行:
<div class="editor-label">
@Html.LabelFor(model => model.User.UserName)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.User.UserName) <!-- THIS LINE -->
@Html.ValidationMessageFor(model => model.User.UserName)
</div>
我的模型是一个ViewModel
具有属性的类:
public RegisterModel User {get;set;}
我已经编写了整个网站,除了重用RegisterModel
. 从那以后,我尝试创建一个全新的Model
被调用NewUserModel
并仅在Area
无济于事的情况下引用它。
我使用DependencyResolver
toNinject
用作我的 IoC/DI。我无法想象这是一个问题......
模型:
namespace MyApplication.Areas.AccountManagement.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
public class NewUserModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[Required, RegularExpression(@"[0-9]{8}", ErrorMessage = "Please enter in an 8 digit Intel Worldwide Id")]
[Display(Name = "WWID")]
public string WWID { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email address")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[System.Web.Mvc.Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}