U4-2724 - UmbracoContext.Current is null when using scheduled publishing

Created by Mads Krohn 26 Aug 2013, 21:52:57 Updated by Sebastiaan Janssen 27 Oct 2015, 12:59:38

I've seen a few people having issues with this, and I've stumbled upon it myself a few times. Whenever you are publishing nodes through scheduled publishing UmbracoContext is simply null.

Since everything regarding creation of an UmbracoContext is internal, this makes it pretty much impossible to do anything related to IPublishedContent and url generation, unless you want to try your luck with reflection and yeah, well, 'nuff said :P

I think the issue with a missing UmbracoContext has been discussed before in other issues, but I haven't seen it mentioned in regard to scheduled publishing, so here goes :)


Dan Booth 21 Mar 2014, 09:13:23

I've found this problem also. Actually, the underlying problem is that HttpContext.Current is often (though not always?) null during a scheduled publish and UmbracoContext relies on this.

This is quite a big issue since people would expect a scheduled publish to work exactly as a manual publish, but if you have custom events that require an HttpContext then you are screwed, as I have found!

Joachim Andersen 04 Sep 2014, 07:28:58

You could try to use the ApplicationContext in you event handler, it also exposes the services and are present as long as the application is started

Johan Benjaminsson 06 Nov 2014, 17:35:23

How can i check if this is the same issue that i'm experiencing? I create a new page, go to properties, enter an "Unpublish at" date in the future and click Publish. When the date comes nothing happens.

Hadi Mirisaee 07 Oct 2015, 00:41:49

This is still an issue on Umbraco version 7.1.4 any solution or quick fix is much appreciated.

Mads Krohn 07 Oct 2015, 07:39:12

I've been maintaining a gist to demo workarounds for different Umbraco versions. Do let me know if you run into any issues -> https://gist.github.com/sniffdk/7600822

Hadi Mirisaee 07 Oct 2015, 22:42:23

Thanks @sniffdk The code resolved my issue.

Mads Krohn 08 Oct 2015, 10:22:45

Great to hear :)

Stephan 15 Oct 2015, 17:24:20

Tried on 7.3.0. Scheduled Publishing is triggered by a request to ScheduledPublishController.Index() - and when entering that method, UmbracoContext.Current is not null - so, whatever happens (event handlers...) during publishing, the context should be here.

So... could not repro on 7.3.0. Ideas?

Mads Krohn 15 Oct 2015, 19:28:38

Haven't tested in 7.3, but will do asap. If this is somehow fixed since 7.1.4, then that is just great. Would be interesting to know what changed though :)

Shannon Deminick 27 Oct 2015, 11:08:23

Hi, we are closing this issue now as we cannot replicate in 7.3.0. If you have steps to replicate the issue please re-open.

Mads Krohn 27 Oct 2015, 11:37:25

Just did a quick test and I can confirm that UmbracoContext.Current is indeed not null when doing scheduled publishing in 7.3, awesome :)

Priority: Normal

Type: Bug

State: Can't Reproduce


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.4, 7.1.4

Due in version:


Story Points: