c# - How can I get the CurrentSite object in Orchard? -


What I'm trying to do, ultimately, is reaching CacheSettingsPart so that I'm programmatic I can do it

  var settings = Services.WorkContext.CurrentSite.As & lt; CacheSettingsPart & gt; (); Settings.IgnoredUrls = Model IgnoredUrls;  

I need something similar to my own method, but when I try IOrchardServices , then WorkContext is null , which means that I do not have access to current site .

Suggestion to get me from an alternative perspective or, ideally, to modify IgnoredUrls current site / .

Edit

  var query = Services.ContentManager.Query & lt; CacheSettingsPart & gt; (); Var cacheSettingsPart = query.List (). first ();  

Above me, what I need, I will now test whether the ignoredUrls is being modified.

Workbench, as far as I can see, is not running due to migration.

You are suggesting that you can get the settings part before - except for the existing site it is probably not used for anything, although you have many tenants, I think That you may be upset.

Inject your code to ISiteService in your migration class.

You can then

  var site = _siteService.GetSiteSettings (); Var cacheSettings = site.As & lt; CacheSettingsPart & gt; ();  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -