Copied to clipboard

Flag this post as spam?

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


  • Gary Cheetham 20 posts 144 karma points
    May 27, 2017 @ 14:24
    Gary Cheetham
    0

    Registering catch-all route to intercept Umbraco content requests

    I'm trying to intercept all requests to Umbraco content nodes and send them to my own RenderMvcController.

    Here's what I have tried (in IApplicationEventHander OnApplicationStarted):

    // Register catch all route
    RouteTable.Routes.MapUmbracoRoute(
        "CatchAllRoutes",
        "{*.}",
        new
        {
            controller = "CatchAll",
            action = "Master"
        }, new ReactUmbracoVirtualNodeRouteHandler());
    

    This works as a catch-all but isn't specific enough, i.e it breaks those backoffice routes which use .axd and requests for favicon.ico, etc....

    The set of routes I want to capture is very specific, and is every route for my content nodes, so it would always be of the pattern /example or /example/2017/05/25/example-post

    So which is the best pattern for me to use?

    Thanks Umbraco friends 👍

  • Yakov Lebski 549 posts 2113 karma points
    May 28, 2017 @ 06:46
    Yakov Lebski
    100

    I think better way is to implement custom default controller, you can find documentation here

Please Sign in or register to post replies

Write your reply to:

Draft