Open Closed

Custom Page Urls #8953


User avatar
0
rafael.gonzales created
  • ABP Framework version: v9.0.5
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

Hello, I've been wondering about one feature I would like to implement.

I have some pages like www.mydomain.com/Books www.mydomain.com/Authors www.mydomain.com/Magazines

but I would like to group some of them like

www.mydomain.com/CustomModule/Books www.mydomain.com/CustomModules/Magazines www.mydomain.com/Configuration/Authors

I am using ABP Studio to generate my sites so I don't want to modify the folder because it will break the url of the scripts generated (principal issue)

Is there a way to handle this task?

Thanks


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi,

    You can manually map your physical .cshtml files to custom paths. Here is an example how it's done in CMS Kit: https://github.com/abpframework/abp/blob/a753ed676687f44949cc013fd17e75b0f4c54ddb/modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs#L113-L128

    If you need more dynamic and determined at the runtime you can go with DynamicRouteTransformer, and here how it can be implemented: https://github.com/abpframework/abp/blob/dev/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKitPageRouteValueTransformer.cs#L46 And registration: https://github.com/abpframework/abp/blob/a753ed676687f44949cc013fd17e75b0f4c54ddb/modules/cms-kit/src/Volo.CmsKit.Public.Web/CmsKitPagesConfigurationExtensions.cs#L29C38-L29C69

    But you wont need the dynamic one, probably manually mapping in the Host project would be enough in your case:

    options.Conventions.AddPageRoute("/Books/Index", "/CustomModule/Books);
    options.Conventions.AddPageRoute("/Authors/Index", "/CustomModule/Authors);
    // ...
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 16, 2025, 12:13