Copied to clipboard

Flag this post as spam?

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


  • Skowronek 29 posts 105 karma points
    Mar 24, 2014 @ 23:55
    Skowronek
    0

    HiJack Umbraco Route Web Forms Site

    I've found this for MVC sites: http://our.umbraco.org/documentation/reference/Templating/Mvc/custom-controllers

    I am hoping someone can provide quick/easy guidance on implementing custom routing prior to having Umbraco parse the request URL without my having to reverse engineering the entire application startup process of Umbraco's source.

    I need to route this: http://www.mysite.com/category/{category}/  through the Umbraco application process to my routed file (/default.aspx), which represents the "/" node of the CMS.

    I've added /category/ to umbracoReservedPaths.

    I'm trying to configure the routes on the global OnApplicationStarting event, but it doesn't even get that far in the application lifecycle.

    Thanks for the help.

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Mar 25, 2014 @ 06:49
  • Skowronek 29 posts 105 karma points
    Mar 25, 2014 @ 17:56
    Skowronek
    1

    Excellent, thanks. I was able to use the IContentFinder per your examples. I appreciate it.

    protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplicationApplicationContext applicationContext)
    {
        ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByNotFoundHandlersMyContentFinder>();
        base.ApplicationStarting(umbracoApplicationapplicationContext);
    }
    
    public class MyContentFinder : IContentFinder
    {
        public bool TryFindContent(PublishedContentRequest contentRequest)
        {
            if (contentRequest != null)
            {
                var path = contentRequest.Uri.GetAbsolutePathDecoded();
    
                if (Regex.Match("^/(topic|category)/(.+?)/?$"RegexOptions.IgnoreCase))
    { var homeNodePath = "/"; var node = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetByRoute(homeNodePath); contentRequest.PublishedContent = node; } } return contentRequest.PublishedContent != null; } }
  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Mar 25, 2014 @ 17:57
    Jeroen Breuer
    0

    Glad I could help. Please mark a post as the solution if it helped you.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies