You need to give WebApi access to the UserManager<ApplicationUser> (AspNetCore.Identity) . To do this, you need to do a mapping ApplicationUser in ApplicationUserDto . An exception is thrown.

 Exception = "\nUnmapped members were found. Review the types and members below.\nAdd a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type\nFor no matching constructor, add a no-arg ctor, add optional arguments, or map all of... 

AutoMapper setting:

 public class MappingProfile : Profile { public MappingProfile() { CreateMap<ApplicationUser, ApplicationUserDto>().ReverseMap(); } } 

DTO:

 public class ApplicationUserDto { public string Id { get; set; } public string UserName { get; set; } public Company Company { get; set; } public string Name { get; set; } public string Role { get; set; } public string Email { get; set; } public string PhoneNumber { get; set; } } 

ApplicationUser:

 public class ApplicationUser : IdentityUser { public Company Company { get; set; } } 

Call the mapper:

 [HttpGet] public async Task<IActionResult> Get() { var users = _userManager.Users.Include(u => u.Company).ToList(); try { var usersDto = _mapper.Map<ApplicationUserDto>(users); } catch (Exception e) { Console.WriteLine(e); //!!!! ЛОВЛЮ ИСКЛЮЧЕНИЕ } await Task.CompletedTask; return new JsonResult(usersDto); } 
  • I suggest you look here: stackoverflow.com/q/832091/261244 - Yaroslav
  • Thank you, why such difficulties? - Aldmi
  • I won’t even say :) - Yaroslav
  • OK, thanks again I will try) - Aldmi
  • should work) - Yaroslav

0