Open Closed

List of AppUser #1258


User avatar
0
cellero created
  • ABP Framework version: v4.3.0
  • UI type: Blazor Server
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): No

Hopefully this is a simple question. I need a list of App Users in a role in .razor.cs.

I can get this for the Current User is ok like this: @using Volo.Abp.Users @inject ICurrentUser CurrentUser .... bool isAdmin = CurrentUser.IsInRole("admin");

Can you please provide some sample code has to how to get a List<AppUser>()

Thank you.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You just need to use IRepository to get users.

    Example:

    public class UserAppService : ApplicationService, IUserAppService
    {
        private readonly IRepository<AppUser, Guid> _appUserRepository;
        
        public UserAppService(IRepository<AppUser, Guid> appUserRepository)
        {
            appUserRepository = _appUserRepository;
        }
        
        public async Task<List<AppUserDto>> GetUserList()
        {
            return ObjectMapper.Map<AppUser,AppUserDto>(await _appUserRepository.GetListAsync());
        }
    }
    
    public partial class Index
    {
        [Inject]
        protected IUserAppService UserAppService { get; set; }
    
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            var users = await UserAppService.GetUserList();
            await base.OnAfterRenderAsync(firstRender);
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.