【发布时间】:2014-12-29 21:37:08
【问题描述】:
我使用 MVC5 和 ASP.NET 身份框架。
我扩展了由 VS2013 搭建的帐户管理功能。
如果我的用户已向外部登录提供商注册并想要添加本地密码,我在调用“AddPasswordAsync()”时会收到错误:“名称不能为空或为空”
我查看了我的数据库并确认用户名不为空。
这个错误是什么意思?
我的 ApplicationUser 如下所示:
public class Person : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Sex Sex { get; set; }
[Display(Name = "Birth date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime Birthdate { get; set; }
public string EMail { get; set; }
public int PostalCode { get; set; }
public Collection<Race> Races { get; set; }
public Collection<Participation> Participations { get; set; }
public Person()
{
if (string.IsNullOrEmpty(UserName))
{
UserName = EMail;
}
Participations = new Collection<Participation>();
Races = new Collection<Race>();
Birthdate = DateTime.Now;
}
}
最好的问候 弗雷德里克
【问题讨论】:
-
您的
ApplicationUser班级是什么样的? -
很抱歉我错过了这个。现在插入了
-
你解决了这个问题吗?我收到“名称不能为空或为空”。错误也是如此。我也将 NAME 属性插入到我的视图模型中,但它仍然给我这个错误。如果你已经解决了,请通过发布它作为答案与我们分享。谢谢
-
嗨阿米尔。唉,我还没有解决这个问题:(
标签: asp.net-mvc asp.net-identity