Copied to clipboard

Flag this post as spam?

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


  • Gary 7 posts 71 karma points
    Jun 04, 2015 @ 07:22
    Gary
    0

    ContentFinderByUrlAlias not working

    Hi, I am trying to use ContentFinderByUrlAlias in my c# code.

    I have my default controller set to:

    DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(TestController));

    and the code within my controller:

    public class TestController: Umbraco.Web.Mvc.RenderMvcController
    {
        public ActionResult Index(RenderModel model)
        {
            var finder = new ContentFinderByUrlAlias();
            var nodeFound = finder.TryFindContent(UmbracoContext.PublishedContentRequest);
            return base.Index(model);
        }
    }
    

    However, the TryFindContent always return false. Can anyone let me know why is that?

    Thanks in advance.

    Gary

  • Doron Uziel 23 posts 93 karma points
    Jun 23, 2015 @ 18:52
    Doron Uziel
    0

    Hi Gary,

    What is it exactly that you are trying to achieve by your code?

    I don't think ContentFinders are ment to be used within a controller, but by the Umbraco pipeline using the ContentFinderResolver.

    So if you wish it to work prior to other IContentFinder You should do it on ApplicationStartEventHandler by calling

    ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByNiceUrl,ContentFinderByUrlAlias>()
    

    So you don't need actually override the default RenderMvcController

Please Sign in or register to post replies

Write your reply to:

Draft