Copied to clipboard

Flag this post as spam?

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

  • Martino 9 posts 110 karma points c-trib
    Oct 27, 2021 @ 11:16

    RenderController in package not working

    I'm trying to implement an Umbraco Package for creating an XML Sitemap.

    My logic is that you create a Content item based on a pre-defined Document Type called XMLSitemap, and then using route hijacking I create a custom controller like this:

    public class XMLSitemapController : RenderController

    My problem is that if I create that controller directly inside my test project everything works as expected, but if I create it inside my package (the code is identical) the controller is not triggered.

    I guess i'm missing something.

  • Martino 9 posts 110 karma points c-trib
    Oct 27, 2021 @ 14:55

    Quick update:
    I found that changing the controller in the package to

    public class XMLSitemapControllerBase : RenderController

    And in the test project inheriting from it, like this:

    public class XMLSitemapController : XMLSitemapControllerBase
        public XMLSitemapController(
            ILogger<RenderController> logger, 
            ICompositeViewEngine compositeViewEngine, 
            IUmbracoContextAccessor umbracoContextAccessor) 
                : base(logger, compositeViewEngine, umbracoContextAccessor)

    with no other additions the code works, but I don't think this is the best solution.
    I would rather not have to create an XMLSitemapController in every project where I install this package.

  • Martino 9 posts 110 karma points c-trib
    25 days ago

    Hey everyone again.

    I was wondering if anyone has some hints on this.

    Thanks :)

Please Sign in or register to post replies

Write your reply to: