Copied to clipboard

Flag this post as spam?

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

  • Thomas Heaney 8 posts 29 karma points
    Feb 28, 2019 @ 16:12
    Thomas Heaney

    Adding custom MVC routes in v8

    Does anyone know how to add custom MVC routes in v8? With v7 I used an ApplicationEventHandler class but this is not available.

    I did make an attempt with Composers and Components but it didn't go very well.

  • Carlos Mosqueda 157 posts 246 karma points
    Feb 28, 2019 @ 16:19
    Carlos Mosqueda

    It looks like so far the documentation has not been update, as you probably saw.

    But if you want to do some digging, in the Umbraco.Web folder, there is a Routing folder and in the main Umbraco.web there is a RouteCollectionExtensions class.

  • seanrock 99 posts 172 karma points
    Mar 17, 2019 @ 10:58

    if you check the github docs repo, there is mention about compositions and that ApplicationEventHandler is gone.

  • seanrock 99 posts 172 karma points
    Mar 17, 2019 @ 14:41
  • Marc Goodson 841 posts 5469 karma points MVP 3x c-trib
    Mar 17, 2019 @ 23:20
    Marc Goodson

    Hi Thomas

    Have knocked up an example here:

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core.Composing; using Umbraco.Web; using Umbraco.Web.Mvc;

    namespace Umbraco8.Components {

    public class RegisterCustomRouteComposer : ComponentComposer<RegisterCustomRouteComponent>
    public class RegisterCustomRouteComponent : IComponent
        public void Initialize()
            RouteTable.Routes.MapUmbracoRoute("Product Details", "product/details/{id}", new
                controller = "SuperProduct",
                action = "Details",
                id = UrlParameter.Optional
            }, new UmbracoVirtualNodeByIdRouteHandler(1105));
        public void Terminate()
            throw new NotImplementedException();


Please Sign in or register to post replies

Write your reply to: