Copied to clipboard

Flag this post as spam?

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

  • Thomas 267 posts 548 karma points c-trib
    Feb 11, 2020 @ 15:34

    _context.EnsureUmbracoContext() - calling a Controller method from a another class


    I'm using this to get a specific node by it's Doctype alias..

    using (var cref = _context.EnsureUmbracoContext())
       IPublishedContentCache cache = cref.UmbracoContext.Content;
       RitzauListPage = cache.GetAtRoot().FirstOrDefault().Descendants().FirstOrDefault(x => x.ContentType.Alias == "ritzauArticleFolder");

    From a another class i'm call my method RitzauController.SyncRitzau(); But when I'm doing that, then _context are null. I'm trying to get hangfire to run my method.

    But if I call my UmbracoApiController method by url then it works.

    Any suggentions how to get around that ?

    My hangfire method

    public void BaselineSync()
            RecurringJob.AddOrUpdate("RitzauSync", () => Ritzau(), Cron.Daily(01, 00));
        public void Ritzau()
Please Sign in or register to post replies

Write your reply to: