Copied to clipboard

Flag this post as spam?

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


  • David Armitage 505 posts 2073 karma points
    Jan 27, 2020 @ 04:09
    David Armitage
    0

    Umbraco 8 | Hangfire | Get Content Errors - Custom properties are all null

    Hi Guys,

    I am wondering if anyone has experienced this issue.

    I am using Hangfire to handle scheduled tasks. I am also using dependency injection within Hangfire to get to my content.

    When I get a content node within Hangfire for some reason all my custom properties are null and also throwing an exception.

    Please see attache. enter image description here

    This is also my method within my ISubscriberHelper class.

    public JobAlertSubscriber GetJobAlertSubscriber(int Id)
            {
                JobAlertSubscriber jobAlertSubscriber;
    
                using (UmbracoContextReference umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext())
                {
                    IPublishedContentCache contentHelper = umbracoContextReference.UmbracoContext.Content;
                    jobAlertSubscriber = contentHelper.GetById(Id) as JobAlertSubscriber;
                }
    
                return jobAlertSubscriber;
            }
    

    I'm assuming that because we are faking the context to acheive dependency injection within Hangfire there is some issues that are still not ironed out.

    I also tried to look up the property values my trying to call the GetProperty methods on the content node and this through the same errors.

  • Maurizio Camporelli 4 posts 74 karma points
    Mar 10, 2020 @ 12:19
    Maurizio Camporelli
    0

    Hi David,

    I'm having exactly the same issue. Not being able to access the properties of the IPublishedModel content is really limiting the usability of the Hangfire functionality within Umbraco 8.

    Did you by any chance find a viable solution?

    Thanks,

    Maurizio

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Mar 10, 2020 @ 14:01
    Nik
    0

    Hi Maurizio,

    I'm working on a blog post on this as I've used hangfire to create and update content.

    You'll probably find that your UmbracoContext is getting disposed of and so it kills the ability to get values back.

    Nik

  • Maurizio Camporelli 4 posts 74 karma points
    Mar 18, 2020 @ 11:12
    Maurizio Camporelli
    0

    Hi Nik,

    That sounds promising! I'm really curious how you managed to work around the inaccessible UmbracoContext. Good luck with your blog post.

    Maurizio

  • Liam Prowse 4 posts 79 karma points
    Oct 06, 2020 @ 15:34
    Liam Prowse
    0

    Hey Nik,

    I know this has been quiet for a while now, but I'm currently facing this issue, how did you resolve it? :)

    Liam

  • David Armitage 505 posts 2073 karma points
    Jun 08, 2021 @ 04:15
    David Armitage
    100

    Hi,

    I did find a solution or hack at least for this. I noticed when using hangfire getting data from Umbraco kind of didn't exist until you try and inspect it.

    Very strange and I have seen similar issues with IEnumerable list. I think something to do with the data only existing in memory until it is requested. It feels like something similar is going on here.

    Anyway my hack was the following.

    See attached for notes. enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft