What I'm trying to do, ultimately, is access the CacheSettingsPart
so that I can programmatically add some ignored URLs to the output caching config.
The relevant admin controller already achieves this with:
var settings = Services.WorkContext.CurrentSite.As<CacheSettingsPart>();
settings.IgnoredUrls = model.IgnoredUrls;
I need something similar for my own method, but when I try and inject IOrchardServices
, the WorkContext
is null
, meaning I don't have access to the CurrentSite
.
I need suggestions of achieving this with an alternative approach or, ideally, a way of accessing the CurrentSite
/CacheSettingsPart
for me to amend the IgnoredUrls
.
EDIT
var query = Services.ContentManager.Query<CacheSettingsPart>();
var cacheSettingsPart = query.List().First();
The above seems to be giving me what I need, I'll now test whether amending IgnoredUrls
persists or not.