Open Closed

How to disable Razor engine so our backend serve pure API #10782


User avatar
0
sinancondo created

We are trying to remove all the references to Lipton template from our project, to keep it only serve API methods. What is the proper way to do that so that no longer Razor Page could be rendered?

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

4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In ABP, “Lepton/LeptonX” is just a UI theme on top of ASP.NET Core MVC/Razor Pages. To make your backend serve pure APIs (and ensure no Razor Page can be rendered), the proper approach is to use the HttpApi.Host project as your host (or convert your current host to the same minimal API host style) and do not include any MVC UI / Razor Pages / Theme modules.

    1) Host only the API (recommended ABP way)

    • Use/run only the *.HttpApi.Host project (tiered solution) as your backend.
    • Ensure your HttpApi.Host module does not depend on any of these kinds of packages/modules:
      • Volo.Abp.AspNetCore.Mvc.UI.*
      • Volo.Abp.AspNetCore.Mvc.UI.Theme.* (Lepton/LeptonX)
      • Any ...Web module that brings MVC UI/Razor Pages

    Result: there are no UI endpoints to render because the host doesn’t include UI at all.

    2) If you must keep a single host, don’t map Razor Pages endpoints

    In your host’s Program.cs, map only controllers (APIs) and don’t map Razor Pages:

    app.UseRouting();
    
    app.UseAuthentication();
    app.UseAuthorization();
    
    app.UseConfiguredEndpoints(endpoints =>
    {
        endpoints.MapControllers();
    
        // Do NOT add this:
        // endpoints.MapRazorPages();
    });
    

    3) Expose only application services as APIs (ABP conventional/auto controllers)

    Enable ABP auto controllers so your Application Services are exposed as REST endpoints (and you don’t need any UI stack):

    using Volo.Abp.AspNetCore.Mvc;
    
    Configure<AbpAspNetCoreMvcOptions>(options =>
    {
        options.ConventionalControllers.Create(typeof(MyProjectApplicationModule).Assembly);
    });
    

    This keeps the backend focused on API endpoints only.

    Sources

    • https://abp.io/docs/latest/framework/api-development/auto-controllers
    • https://abp.io/support/questions/10577
    • https://abp.io/docs/latest/framework/ui/mvc-razor-pages/theming

    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.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    Yes, this is doable. The clean ABP setup for it is the separated (non-bundled) architecture: the API host references your HttpApi / Application / EF layers plus JWT bearer auth, and it does not include the LeptonX theme or the Account login UI. That already removes the whole Lepton / MVC UI surface, which is the main thing you're after.

    Two things worth knowing so there are no surprises:

    • Login is the main reason Razor sticks around. The interactive login screen is a Razor Page from the Account module, and OpenIddict renders it for browser-based sign-in. So if this backend still needs users to log in through a browser, keep that in a dedicated Auth Server project and let the API host stay UI-free. If auth is purely token-based (a separate Auth Server / frontend / external IdP handles login), the API host needs no login UI at all.
    • If your goal is literally zero Razor Pages, note that ABP's MVC maps Razor Pages by default and a couple of framework UI modules still ship one (for example the multi-tenancy tenant-switch UI), so you'd also remove those *.Mvc.UI.* modules, not just the LeptonX theme.

    To give you the exact modules and packages to strip out for your project, could you share:

    1. ABP version and template (app / microservice, and MVC / Blazor / Angular).
    2. Is your solution single-project (the host also renders the UI and acts as the auth server), or already split into separate HttpApi.Host / AuthServer projects?
    3. Does this backend still need to serve an interactive browser login, or is auth purely token-based?

    With that I'll give you the precise list of module DependsOn entries and PackageReferences to remove.

    Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    sinancondo created

    thank you very much

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You're welcome. Whenever you're ready, just share your project structure (version, template, single-project vs separated) and whether you still need a browser login, and I'll send you the exact module/package changes for your project.

    Thanks

    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 21, 2026, 06:18
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.