Dear ABP Support Team,
I am working on a solution with the following environment:
- ABP Framework: 9.0.4
- UI Type: Blazor Server (with separated Auth Server)
- Theme: LeptonX 4.0.5
- Database: SQL Server (.NET 9.0)
Requirement: I need to implement a fully customized registration and login flow. This includes:
- UI Modification: Customizing the HTML/CSS for both pages.
- Backend Logic: Overriding the default authentication and registration processes (e.g., adding custom validation or third-party service calls during sign-up).
- Database Extension: Storing additional custom fields in the AbpUsers table.
My Investigation So Far: I understand that I can override the UI by creating Login.cshtml and Register.cshtml in the Auth Server project. However, I need specific guidance on the following "Tiered" architecture complexities:
- Logic Overriding: What is the best practice for overriding the RegisterModel and LoginModel in ABP 9.0.4 to ensure my custom backend logic is executed?
- Database Persistence: Since I have a separated Auth Server, should I use the Module Entity Extension System in the .Domain.Shared project to ensure my new database fields are recognized across the entire tiered solution?
- LeptonX Compatibility: Are there specific LeptonX account layouts I should inherit from to maintain the theme's responsive sidebar and styling during the custom login process?
Could you please provide a recommended approach or a code sample for extending the backend logic of the AccountModule specifically for a tiered .NET 9.0 setup?
Thank you for your assistance.
1 Answer(s)
-
0
- Tiered auth-server setup (Blazor Server UI + separated Auth Server): Do all login/registration UI + backend flow overrides in the Auth Server (the project that actually hosts
/Account/Loginand issues the auth cookies/tokens). The Blazor Server UI typically redirects to the Auth Server for authentication; changing Blazor UI won’t change the auth flow itself.
1) Override UI (HTML/CSS) in the Auth Server
- In the AuthServer project, create:
Pages/Account/Login.cshtmlPages/Account/Register.cshtml
- Copy the original markup from the Account Module page(s) and modify HTML/CSS as you need.
- Keep theme styling by continuing to use the Account layout (usually it’s already applied by the theme). Practically, the safest approach is: copy the original page and only adjust the parts you need (classes/structure), so you don’t accidentally drop required ABP tag helpers/bundles.
(This is the official “override Razor Page” mechanism used by ABP.)
- In the AuthServer project, create:
2) Override backend logic: extend/replace
LoginModel/RegisterModelABP’s recommended way for Razor Pages is to create your own PageModel that derives from the module’s PageModel and then point the.cshtmlto your custom model using@model.Custom login PageModel (Auth Server project):
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Volo.Abp.Account.Web; using Volo.Abp.Account.Web.Pages.Account; namespace MyCompany.MyProject.AuthServer.Pages.Account; public class CustomLoginModel : LoginModel { public CustomLoginModel( IAuthenticationSchemeProvider schemeProvider, IOptions<AbpAccountOptions> accountOptions) : base(schemeProvider, accountOptions) { } public override async Task<IActionResult> OnPostAsync(string action) { // 1) Your custom validation / 3rd-party checks here // 2) Then continue with the default ABP login behavior return await base.OnPostAsync(action); } }Then in
Pages/Account/Login.cshtmlset:@page @model MyCompany.MyProject.AuthServer.Pages.Account.CustomLoginModelDo the same pattern for Register: create
CustomRegisterModel : RegisterModel, override the method(s) you need, then set@modelinRegister.cshtml.Notes (important):
- Naming convention matters: If your class name doesn’t end with
LoginModel/RegisterModel, you may need to replace via DI. If you follow the convention, you can typically just reference it from the.cshtmlusing@modelas shown in ABP docs. - In some setups using OpenIddict-supported account pages, ABP docs note the base model can differ. (If your solution uses the OpenIddict variants, follow that note and inherit from the OpenIddict-supported model instead of plain
LoginModel.)
3) Persist extra fields in
AbpUsers(tiered + separated Auth Server) Yes: in a tiered solution with a separated Auth Server, the Module Entity Extension System is the correct approach so the extra properties are known across the solution (contracts/shared) and are mapped properly where Identity is used.The key idea:
- Define the extra properties in your
.Domain.Shared(so DTOs/UI can “know” the properties). - Ensure EF Core mapping is applied in the project that owns the IdentityDbContext / migrations (commonly the Auth Server’s EF Core layer / DbMigrator path in a tiered setup).
(The concrete mapping code depends on your existing solution structure, but the correct direction is: Entity Extension System in Domain.Shared + EF Core mapping/migrations applied where identity DB schema is managed.)
- Define the extra properties in your
4) LeptonX compatibility (keeping account look & responsive layout) For LeptonX (and ABP themes generally), the most robust method is:
- Copy the existing Login/Register Razor pages from the module and modify minimally.
- That preserves the theme’s account layout usage and bundling conventions that produce the responsive styling.
If you completely rewrite markup, you risk dropping the layout/bundle hooks that the theme uses.
Links (validated)
- ABP UI customization (override Razor Pages):
https://abp.io/docs/latest/framework/ui/mvc-razor-pages/customization-user-interface - ABP community guide: “How to Customize the Login Page for MVC / Razor Page Applications” (shows the same inherit-and-override pattern):
https://abp.io/community/articles/9a40f3cd - Account module docs:
https://abp.io/docs/latest/modules/account - Account Pro docs (if you’re using Account Pro):
https://abp.io/docs/latest/modules/account-pro - Account module Login page source (to copy markup):
https://github.com/abpframework/abp/blob/dev/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml - Account module Login PageModel source (to see what to override):
https://github.com/abpframework/abp/blob/037ef9abe024c03c1f89ab6c933710bcfe3f5c93/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
- Tiered auth-server setup (Blazor Server UI + separated Auth Server): Do all login/registration UI + backend flow overrides in the Auth Server (the project that actually hosts