Copied to clipboard

Flag this post as spam?

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


  • Tobbe 81 posts 387 karma points c-trib
    Feb 06, 2018 @ 12:46
    Tobbe
    0

    UmbracoContext.EnsureContext vs UmbracoContext.CreateContext

    Im using https://www.quartz-scheduler.net to schedule some archiving in Umbraco. Since these "jobs" are done outside of UmbracoContext (not started by a web request) I have to create the UmbracoContext myself (right?). I do this by calling:

    var umbContext = UmbracoContext.CreateContext(
                    dummyHttpContext,
                    ApplicationContext.Current,
                    new WebSecurity(dummyHttpContext, ApplicationContext.Current),
                    UmbracoConfig.For.UmbracoSettings(),
                    UrlProviderResolver.Current.Providers,
                    false)
    var umbHelper = new UmbracoHelper(umbContext);
    // bla bla bla do stuff
    

    But I just noticed UmbracoContext.CreateContext. What is the difference from UmbracoContext.CreateContext and when should I use which?

    I also wonder if its safe to use these? Will they be "destroyed" when my "Jobs"-code has been finished?

Please Sign in or register to post replies

Write your reply to:

Draft