Content-tree based routing not working in MVC 12 to 13 upgrade (ASP.Net Framework)

Stephen Rushing asked on May 11, 2023 01:37

I'm in the process of upgrading a v12 instance to 13. The Kentico admin side has all gone pretty smoothly (except for preview), but I'm running into issues with routing on the MVC instance.

We've been using DevTrev's DynamicRouting, and I've followed his instructions for migrating the URLs to the CMS_PageUrlPath table.

Note: I have NOT finished removing the addon from the admin, but considering the CMS_PageURLPath table is populated, I don't think that's necessary to make the routing work.

Other checkpoints:

  • Conent-tree based routing is enabled in the system settings, and the Home page is selected (/Home).
  • I have replaced the routing attributes on all respective controllers, i.e. [assembly: RegisterPageRoute(CMS.DocumentEngine.Types.Lummus.HomePage.CLASS_NAME, typeof(HomeController), ActionName = "Index")]
  • My RouteConfig.RegisterRoutes method has the following:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        // route for sitemap
        routes.MapRoute(
           name: "Sitemap",
           url: "sitemap.xml",
           defaults: new { controller = "Sitemap", action = "Index" }
       );
    
        // route for robots
        routes.MapRoute(
            name: "Robots",
            url: "robots.txt",
            defaults: new { controller = "Robots", action = "Index" }
        );
    
        // route for manifest.json
        routes.MapRoute(
            name: "Manifest",
            url: "manifest.json",
            defaults: new { controller = "Manifest", action = "Index" }
        );
    
        // Map routes to Kentico HTTP handlers
        routes.Kentico().MapRoutes();
    
  • The sitemap.xml and robots.txt routes are working

All pages return 404s

The root URL returns a 403.14 error about not listing the directory contents, and any URLs of actual pages, including /Home, return a 404 from the StaticFile handler, so the appropriate routes or controllers are not picking up the requests.

Module     IIS Web Core
Notification       MapRequestHandler
Handler    StaticFile
Error Code     0x80070002

Correct Answer

Arjan van Hugten answered on May 11, 2023 09:31

Have you added the 'UsePageRouting' in your 'Application_Start' or 'Startup.cs'?

0 votesVote for this answer Unmark Correct answer

Recent Answers


Stephen Rushing answered on May 11, 2023 17:59 (last edited on May 11, 2023 18:02)

I'm only finding that in the .Net Core docs, not the .Net Framework routing docs.

The IApplicationBuilder instance in ApplicationConfig.RegisterFeatures() doesn't appear to have that method.

Am I missing it?

0 votesVote for this answer Mark as a Correct answer

Stephen Rushing answered on May 11, 2023 18:10

Nevermind, I found it here. And the issue was that I needed to import the Kentico.Content.Web.Mvc.Routing namespace for the UsePageRouting extention method on the builder instance.

Thanks very much for pointing me in the right direction!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.