我安装了数据注解MVC3 (我使用的是MVC3),但是找不到我的EmailAddress数据注解。我在网上搜索了一下,我不明白为什么它没有引用。
这是我的模型:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
namespace Projectx.Models
{
public class PreSignUpUser
{
[Required]
[EmailAddress]
public string Email { get; set; }
}
}有人能帮帮我吗?
发布于 2011-11-23 03:06:58
也许你可以试试这个:
[DataType(DataType.EmailAddress)]代替
[EmailAddress]发布于 2011-11-23 15:01:54
您要查找的数据注释实际上是电子邮件。
EmailAddress不是数据注释扩展的一部分。
发布于 2018-03-01 23:09:54
对我来说,这些答案并不管用。我通过添加System.ComponentModel.Annotations nuget包解决了这个问题,然后添加了引用
using System.ComponentModel.DataAnnotations;如果您还没有这样做的话。
https://stackoverflow.com/questions/8232223
复制相似问题