title: .Net asynchronously calling a partial view
body: <p>I am hitting a bit of a bug when I am trying to render a partial view that basically displays some slides in a slidereel. </p>
  
  <p>The slides are stored in the db and I know from debugging that my controller method is definitely getting an array of slide objects.</p>
  
  <p>But it is still throwing this error and I am not sure why. The error I am getting is:</p>
  
  <p>{"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."} with the inner exception of:</p>
  
  <p>HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.</p>
  
  <p>I am assuming it is something to do with synchronization, but I am not sure what.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Parent View (index)</p>
  
  <pre><code>@{
      ViewBag.Title = "Title";
      Layout = "~/Views/Shared/_Layout.cshtml";
  
      ViewBag.IsIndex = true;
  }
  
  &lt;!-- BEGIN .featured-slider --&gt;
  &lt;div class="featured-slider"&gt;
      &lt;!-- BEGIN .slider-background --&gt;
      &lt;div class="slider-background"&gt;
          &lt;!-- BEGIN .row --&gt;
          &lt;div class="row"&gt;
              &lt;!-- BEGIN .sixteen columns --&gt;
              &lt;div class="sixteen columns"&gt;
                  @{
                      Html.RenderAction("Slideshow", new { controller = "home" });
                  }
               &lt;!-- END .sixteen columns --&gt;
              &lt;/div&gt;
          &lt;!-- END .row --&gt;
          &lt;/div&gt;
      &lt;!-- END .slider-background --&gt;
      &lt;/div&gt;
  &lt;!-- END .featured-slider --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Controller method:</p>
  
  <pre><code>    public async Task&lt;PartialViewResult&gt; Slideshow()
      {
          var slides = await _slides.GetPublishedSlidesAsync();
  
          return PartialView("_Slideshow", slides);
      }
  </code></pre>
  
  <p>_Slideshow partial view:</p>
  
  <pre><code> @model IEnumerable&lt;Models.Slide&gt;
  
  &lt;!-- BEGIN .slideshow --&gt;
  &lt;div class="slideshow radius-full"&gt;
      &lt;!-- BEGIN .flexslider --&gt;
      &lt;div class="flexslider radius-full" control-nav="true" data-speed="10000" data-transition="slide"&gt;
          &lt;!-- BEGIN .slides --&gt;
          &lt;ul class="slides"&gt;
              @foreach (var slide in Model)
              {
                  &lt;li&gt;
                      &lt;!-- BEGIN .sixteen columns --&gt;
                      &lt;div class="sixteen columns"&gt;
                          if(false)
                          { 
                              &lt;div class="feature-vid"&gt;
  
                              &lt;/div&gt;
                          }
                          else if (true)
                          {
                              &lt;a class="feature-img radius-full" href="" rel="bookmark" title=""&gt;
                                  &lt;img src="@slide.Image" /&gt;
                              &lt;/a&gt;
                              if (false)
                              {
                                  &lt;!-- BEGIN .information --&gt;
                                  &lt;div class="information radius-full"&gt;
                                      &lt;div class="six columns"&gt;
                                          &lt;h2 class="headline small"&gt;qqqq&lt;/h2&gt;
                                      &lt;/div&gt;
                                      &lt;div class="ten columns"&gt;
                                          &lt;div class="excerpt"&gt;aaaa&lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;!-- END .information --&gt;
                                  &lt;/div&gt;
                              }
                          }
                      &lt;!-- END .sixteen columns --&gt;
                      &lt;/div&gt;
                  &lt;/li&gt;
              }
          &lt;!-- END .slides --&gt;
          &lt;/ul&gt;
      &lt;!-- END .flexslider --&gt;
      &lt;/div&gt;
  &lt;!-- END .slideshow --&gt;
  &lt;/div&gt;
  </code></pre>