Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John DeSpirito 10 posts 80 karma points
    Jan 13, 2023 @ 14:24
    John DeSpirito
    0

    How do I map routing to an mvc area with Umbraco?

    Hey All,

    In our project we've set up an area called "Migration" where we're putting codethat migrates all our old site's content. Where I'm running into trouble is when I configure the routing in startup.cs.

    I've tried this:

                app.UseUmbraco()
                .WithMiddleware(u =>
                {
                    u.UseBackOffice();
                    u.UseWebsite();
                })
                .WithEndpoints(u =>
                {
                    u.EndpointRouteBuilder.MapControllerRoute(
                    name: "Migration",
                    pattern: "{area:exists}/{controller}/{action=Index}/{id?}");
                    u.UseInstallerEndpoints();
                    u.UseBackOfficeEndpoints();
                    u.UseWebsiteEndpoints();  
                });
    

    Which successfully routed the area, however, it broke the umbraco admin screens (they appear to be empty with a number of routing errors listed in the console.)

    I feel I'm probably missing something obvious with how to do areas in Umbraco core, can anyone help?

    Thanks!

    John

  • John DeSpirito 10 posts 80 karma points
    Jan 13, 2023 @ 14:36
    John DeSpirito
    0

    Oops! Found the solution 10 minutes after I posted of course. For anyone else who needs to know this, EndpointRouteBuilder has a MapAreaControllerRoute function, which worked. Don't know why I missed that in the documentation, didn't turn up in my google searches.

Please Sign in or register to post replies

Write your reply to:

Draft