Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Sep 07, 2015 @ 13:17
    Lee
    0

    Query & Update Umbraco Data With HttpContext?

    I'm working with Quartz.net tasks, and when a scheduled task is fired I'd like to be able to query some data and (maybe) update some content values.

    However, unless I'm being stupid (Highly likely) I cannot query data unless the HttpContext is available?

    I thought this would work.

    UmbracoContext.Current.ContentCache.GetByXPath("//MyDocType");
    

    But

    UmbracoContext.Current
    

    is null (Just like HttpContext.Current).

    Also, I'm guessing that the new Services won't work without the HttpContext?

    Any help appreciated.

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Sep 08, 2015 @ 09:47
    Dan Diplo
    0

    Yeah, as far as I understand the UmbracoContext relies on HttpContext and is currently fairly tightly coupled to it.

    The way I've gotten around this previously is to expose the data you want to be queried (or updated) via Umbraco API controllers - basically, as simple REST-like services. So you would call an API controller from your Quartz task to get back your data (as XML or JSON).

Please Sign in or register to post replies

Write your reply to:

Draft