In this tutorial, you will learn how to correctly register custom routes within Umbraco 8. It is also possible to create your own custom routes. Pre 8 Umbraco used the standard .NET approach to route handling was done within the global.ascx. First, you would register a custom Route handler. Next, somewhere in your codebase, usually 'App_Start' create a RouteConfig.cs that contained a list of custom routes. As of Umbraco 8, this is no longer the recommended approach.
In Umbraco V8 the concept of components was introduced. Components are the new way how you can hook into the Umbraco request pipeline to run some custom code, like adding custom routes. The focus of this article is writing a component specifically for routing rather than an introduction to components. If you need to register an MVC controller, or you need to do something non-Umbraco with your routes, then read on.
Registering A Component
Registering and creating a new component within Umbraco is very easy. First, you will need to create a class to register the component, this looks like this:
In this example
RegisterCustomRouteComponent is the custom component we will now create:
In this example, I have now registered access to a standard MVC controller that looks like this:
RegisterCustomRouteComponent you are now free to use it in the same manner as you would a file like