Asp.net 值不能为null。参数名称:value
我想在aspnet用户表中添加新字段。我还在帐户视图模型中添加了username属性Asp.net 值不能为null。参数名称:value,asp.net,asp.net-identity,customization,Asp.net,Asp.net Identity,Customization,我想在aspnet用户表中添加新字段。我还在帐户视图模型中添加了username属性 public class ApplicationUser : IdentityUser<int, UserLogin, UserRole, UserClaim> { public DateTime? ActiveUntil; public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationU
public class ApplicationUser : IdentityUser<int, UserLogin, UserRole, UserClaim>
{
public DateTime? ActiveUntil;
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public string UserName { get; set; }
我通过在SecurityStamp字段中放入一个随机字符串解决了这个问题。要生成此字符串,只需使用Guid.NewGuid() 因此,您可以将代码更改为如下内容:
在此处输入code
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
{
if (string.IsNullOrEmpty(this.SecurityStamp))
{
this.SecurityStamp = Guid.NewGuid().ToString().Replace("-", "");
}
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
公共异步任务GenerateUserIdentityAsync(ApplicationUserManager)
{
if(string.IsNullOrEmpty(this.SecurityStamp))
{
this.SecurityStamp=Guid.NewGuid().ToString().Replace(“-”,”);
}
var userIdentity=wait manager.CreateIdentityAsync(这是DefaultAuthenticationTypes.ApplicationOkie);
返回用户身份;
}
我也面临同样的错误。当我将[Display]
更改为以下内容时,我发现在模型中
:
[Display(Name = "")]
public string Budget { get; set; }
与此相反:
[Display(Name = "Budget")]
public string Budget { get; set; }
姓名的
值
未定义…@TAHA SULTAN TEMURI您能更详细地解释一下您获得奖金的原因吗?这个问题已经很老了,看起来已经得到了充分的回答(虽然OP没有接受)。实际上,我几周前就遇到了同样的问题,所以我决定开始悬赏,就在那时我找到了解决方案,这就是为什么现在等待结束的原因。
[Display(Name = "Budget")]
public string Budget { get; set; }