Quantcast
Channel: Using Optimizely Platforms
Viewing all articles
Browse latest Browse all 8020

IUrlResolver returning null in Initialization Module but not in Scheduled Job

$
0
0

I've a scheduled job that was (and still is) working fine, but I've also refactored the code so that it can be called from a Initialization module, so job can be run from a scheduled task, but should also be run when EpiServer 'boots up'.

The Problem: 

// where urlResolver == IUrlResolver 
// where homePage.Error404Page == ContentReference
string 404Url = _urlResolver.GetUrl(homePage.Error404Page)  // returns null

Why is this only returning null in the initialization module? I thought maybe it has something to do with Initialization Module dependencies, so according to https://gregwiechec.com/2015/11/sort-order-of-module-dependencies/ I also added 'EPiServerUIInitialization' (which is near the bottom of the list) as an extra dependency, but it didn't help

[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
[ModuleDependency(typeof(EPiServer.UI.EPiServerUIInitialization))]
public class ErrorPagesInitializationModule : IInitializableModule

Any suggestions to get this working??


Viewing all articles
Browse latest Browse all 8020

Trending Articles