Search code examples
abp-framework

ABP 4.0 Blazor - Overriding Identity Views


I am trying out ABP 4.0 using the Blazor UI and want to override the built-in view for User Management. Inspecting the source code I found the UserManagement.razor file which has the route of "/identity/users" - this matches the view that I want to override.

I have (I believe) followed the steps listed at: https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components. However when running the site, I still get the standard, built-in user list.

Pages/Identity/UserManagement.razor (within my wwwroot folder):

@inherits Volo.Abp.Identity.Blazor.Pages.Identity.UserManagement
<h2>This is not the standard page</h2>

Pages/Identity/UserManagement.razor.cs

using Volo.Abp.DependencyInjection;

namespace BlazorDemo.Blazor.Pages.Identity
{
    [ExposeServices(typeof(UserManagement))]
    [Dependency(ReplaceServices = true)]
    public partial class UserManagement
    {
    }
}

Have I missed something here?


Solution

  • Use a diffent name for your own component, like MyUserManagement.razor. Otherwise, compoiler can not distinguish the classes. For example,

    using Volo.Abp.DependencyInjection;
    
    namespace BlazorDemo.Blazor.Pages.Identity
    {
        [ExposeServices(typeof(UserManagement))] //MUST BE Volo.Abp.Identity.Blazor.Pages.Identity.UserManagement
        [Dependency(ReplaceServices = true)]
        public partial class UserManagement
        {
        }
    }
    

    Here, ExposeServices exposes itself (your class) instead of the Volo.Abp.Identity.Blazor.Pages.Identity.UserManagement. If you rename your component to MyUserManagement than you don't make such mistakes :)