title: Unable to save to HttpRuntime.Cache while in an async Task
body: <p>I am modifying some code to do XYZ and such and am running into an issue.</p>
  
  <p>WebAPI method</p>
  
  <pre><code>public async Task&lt;FileUploadResult&gt; PostFile([FromUri]int width)
  {
      // Right here the HTTPContext.Current == null;
      ... Some code here
      await Request.Content.ReadAsMultipartAsync(streamProvider);
  }
  </code></pre>
  
  <p>I have looked and seen that this line will restore your HttpContext.Current</p>
  
  <pre><code>add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"
  </code></pre>
  
  <p>So I have added the above setting and it returns the HttpContext.Current.
  From what I can tell I can access (read) the .Cache object from both HttpContext.Current.Cache and HttpRuntime.Cache.</p>
  
  <p>but, for some reason I cannot write to the cache, successfully anyways.</p>
  
  <p>My code does not throw an exception, but when I try to read the cache it simply not there.</p>
  
  <p>My code works very well everywhere else, just not inside an async web api call.</p>
  
  <p>Cache Code</p>
  
  <pre><code>private Cache sysCache = HttpContext.Current.Cache;
  // also treid  private Cache sysCache = HttpRuntime.Cache
  sysCache.Insert(fileToCache.ToMD5HashString(), 
                          fileToCache,
                          null,
                          Cache.NoAbsoluteExpiration,
                          new TimeSpan(0, 0, 5, 0));
  </code></pre>
  
  <p>Any help on this issue would be greatly appreciated.</p>
  
  <p>Thanks in advance.</p>