title: Preventing a deadlock when calling an async method without using await
body: <p>I need to call a method returning a <code>Task</code> from within</p>
  
  <pre><code>public override void OnActionExecuting(ActionExecutingContext filterContext)
  </code></pre>
  
  <p>It wont let me make this method async it throws the following</p>
  
  <blockquote>
    <p>An asynchronous module or handler completed while an asynchronous
    operation was still pending.</p>
  </blockquote>
  
  <p>and when calling </p>
  
  <pre><code> entityStorage.GetCurrentUser().Result
  </code></pre>
  
  <p>I get a deadlock. How can I avoid this? </p>
  
  <p>I have been playing around with it coming up with stuff like </p>
  
  <pre><code>entityStorage.GetCurrentUser().Result.ConfigureAwait(false).GetAwaiter().GetResult();
  </code></pre>
  
  <p>But this isn't working. How can I do it? My solution will need to work with ASP.NET 4 and the Async Targetting Pack, I can't use ASP.NET 4.5 as am deploying to Azure.</p>