title: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete
body: <p>I have an asp.net mvc app with a partial view to render the User Profile Name</p>
  
  <pre><code>@{ Html.RenderAction("GetPropertiesForUser", "UserProfile"); }
  
  @model Inspinia_MVC5_xx.Models.UserProfile
  &lt;div class="dropdown profile-element"&gt;
      &lt;span&gt;
          &lt;img alt="image" class="img-circle" src="~/Images/profile_small.jpg" /&gt;
      &lt;/span&gt;
      &lt;a data-toggle="dropdown" class="dropdown-toggle" href="#"&gt;
          &lt;span class="clear"&gt;
              &lt;span class="block m-t-xs"&gt;
                  &lt;strong class="font-bold"&gt;@Model.displayName&lt;/strong&gt;
              &lt;/span&gt; &lt;span class="text-muted text-xs block"&gt;Art Director &lt;b class="caret"&gt;&lt;/b&gt;&lt;/span&gt;
          &lt;/span&gt;
      &lt;/a&gt;
      &lt;ul class="dropdown-menu animated fadeInRight m-t-xs"&gt;
          &lt;li&gt;&lt;a href="@Url.Action("Profile", "AppViews")"&gt;Profile&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="@Url.Action("Contacts", "AppViews")"&gt;Contacts&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="@Url.Action("Inbox", "Mailbox")"&gt;Mailbox&lt;/a&gt;&lt;/li&gt;
          &lt;li class="divider"&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="@Url.Action("Login", "Pages")"&gt;Logout&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class="logo-element"&gt;
      IN+
  &lt;/div&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>public class UserProfileController : Controller
  {
      public async Task&lt;ActionResult&gt; GetPropertiesForUser()
      {
          Uri serviceRoot = new Uri(SettingsHelper.AzureAdGraphApiEndPoint);
          var token = await AppToken.GetAppTokenAsync();
  
          ActiveDirectoryClient adClient = new ActiveDirectoryClient(
           serviceRoot,
           async () =&gt; await AppToken.GetAppTokenAsync());
          string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
  
          Microsoft.Azure.ActiveDirectory.GraphClient.Application app = (Microsoft.Azure.ActiveDirectory.GraphClient.Application)adClient.Applications.Where(
              a =&gt; a.AppId == SettingsHelper.ClientId).ExecuteSingleAsync().Result;
          if (app == null)
          {
              throw new ApplicationException("Unable to get a reference to application in Azure AD.");
          }
  
          string requestUrl = string.Format("https://graph.windows.net/{0}/users/{1}?api-version=1.5", SettingsHelper.Tenant,ClaimsPrincipal.Current.Identities.First().Name);
  
          HttpClient hc = new HttpClient();
          hc.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(
              "Bearer", token);
  
          HttpResponseMessage hrm = await hc.GetAsync(new Uri(requestUrl));
  
          if (hrm.IsSuccessStatusCode)
          {
              UserProfile up = JsonConvert.DeserializeObject&lt;UserProfile&gt;(await hrm.Content.ReadAsStringAsync());
              return PartialView(up);
              //return View("GetPropertiesForUser", new UserProfile
              //{
              //    DisplayName = up.displayName() //I am still missing here to get the display name only
              //});
          }
          else
          {
              return View();
          }
      }
  
  }
  </code></pre>
  
  <p>However I get this error</p>
  
  <blockquote>
    <p>HttpServerUtility.Execute blocked while waiting for an asynchronous
    operation to complete. Description: An unhandled exception occurred
    during the execution of the current web request. Please review the
    stack trace for more information about the error and where it
    originated in the code.</p>
    
    <p>Exception Details: System.InvalidOperationException:
    HttpServerUtility.Execute blocked while waiting for an asynchronous
    operation to complete.</p>
    
    <p>Source Error:</p>
    
    <p>Line 4:               Line 5:<br>
     Line 6:            @{
    Html.RenderAction("GetPropertiesForUser", "UserProfile"); } Line 7:<br>
    </li> Line 8:              </p>
  </blockquote>
  
  <p>How can I fix this?</p>