我尝试从AspNetUsers
表中获得一位特定用户,但在ASP.Net Core中没有成功。
这是我尝试的代码:
[HttpGet]
[Route("employee/{id}")]
public async Task<Object> GetSpecificUser(string id)
{
var user = await _userManager.FindByIdAsync(id);
return Ok(user);
}
// and
[HttpGet]
[Route("employee/{id}")]
public IActionResult GetSpecificUser(string id)
{
var user = _userManager.Users.FirstOrDefault(x => x.Id == id);
return Ok(user);
}