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