作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经成功验证了我的应用程序,但我似乎唯一不能做的就是更改我所做的用户属性。
public async Task<IActionResult> OnPostAsync()
{
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
if (!ModelState.IsValid)
{
LoadAsync(user);
return Page();
}
var phonenumber = await _userManager.GetPhoneNumberAsync(user);
if (Input.PhoneNumber != phonenumber)
{
var setPhoneNumber = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber);
}
user.FirstName = Input.FirstName;
return RedirectToPage();
}
如果有人知道如何更改
FirstName
属性(property),谢谢。
最佳答案
I have successfully authenticated my app, but the only thing that I can't seem to do is change the user properties that I have made.
UserManager<TUser>.UpdateAsync(TUser)
method更新指定的用户,如下所示。
//set FirstName of current user
user.FirstName = Input.FirstName;
//update the specified user
await _userManager.UpdateAsync(user);
关于asp.net-mvc - 如何在 .NET Core 中更改 SQL 数据库中的 FirstName 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65983073/
我是一名优秀的程序员,十分优秀!