I'm using Hangfire and Umbraco and am using some of the umbraco services in the business layer that runs in Hangfire. These are being registered in an IOC container like this:
container.Register<IMemberService>((f)=>ContextHelpers.EnsureUmbracoContext().Application.Services.MemberService, new PerScopeLifetime());
container.Register<IMemberGroupService>((f) => ContextHelpers.EnsureUmbracoContext().Application.Services.MemberGroupService, new PerScopeLifetime());
All this works great until I enable the always on preloader to ensure that Hangfire is always running. The ApplicationContext.Current is null. Is there a better way or alternate way to do the EnsureUmbracoContext so that it is initialized in the preloader?
Error:
Message: Current has not been initialized on Umbraco.Web.Routing.UrlProviderResolver. You must initialize Current before trying to read it.
Hangfire Always On IIS 7.5/8.0 and Preloading
I'm using Hangfire and Umbraco and am using some of the umbraco services in the business layer that runs in Hangfire. These are being registered in an IOC container like this:
All this works great until I enable the always on preloader to ensure that Hangfire is always running. The ApplicationContext.Current is null. Is there a better way or alternate way to do the EnsureUmbracoContext so that it is initialized in the preloader?
Error:
Preloader:
I went a different route using the iis extension to autoload the site. Seems to be working fine.
I'm having the same issue.
I'm thinking it's because Hangfire BackgroundJobServer is not being instantiated in the OWIN start up, but in IProcessHostPreloadClient.Preload.
Would love a fix or some tips...
is working on a reply...