首页 新闻 会员 周边

ASP.NET MVC 创建外部登录时出现安全标签错误

0
悬赏园豆:5 [已关闭问题] 关闭于 2018-04-12 14:49

在ASP.NET MVC中,我使用_userManager创建外部登录时,出现以下错误:

1 var user = _userManager.FindByIdAsync("111");
2 var item = await _userManager.AddLoginAsync(user, new UserLoginInfo("SMS", model.PhoneNbr, "SMS"));

目的,希望用户用手机号码登录了以后,自动在AspNetUserLogins表中创建一条数据以关联当前查询到的用户。

 

在再执行的时候,系统系统提示以下错误:

An unhandled exception occurred while processing the request.
An unhandled exception occurred while processing the request.
InvalidOperationException: User security stamp cannot be null.
Microsoft.AspNetCore.Identity.UserManager+<ValidateUserInternal>d__169.MoveNext()

这个时候用户还没有登录,我想在用户登录之前,将这个手机号码直接绑定给这个用户,然后再直接登录。

denli的主页 denli | 初学一级 | 园豆:19
提问于:2018-04-12 13:54
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册