title: asp.net Core 2 Razor Pages problem loading partial inside conditional
body: <p>I created a partial page view that is a box that for displaying form validation errors:</p>
  
  <pre><code>&lt;div class="alert alert-danger" role="alert"&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-auto align-self-center"&gt;
          &lt;i class="fas fa-times-circle fa-2x"&gt;&lt;/i&gt;
      &lt;/div&gt;
      &lt;div asp-validation-summary="All"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>From the main page view, I want to load this partial page view only if any validation errors exist:</p>
  
  <pre><code>@if (ViewData.ModelState.ErrorCount &gt; 0)
  {
      &lt;partial name="Partial/_ValidationErrorSummary"/&gt;
  }
  </code></pre>
  
  <p>When I first load the page the error summary does not display, which is what I want. But when I try to submit the form on the page nothing happens. If I remove the conditional <code>@if (ViewData.ModelState.ErrorCount &gt; 0)</code> from the main page view, I am able to submit the form as expected. What am I doing wrong?</p>
  
  <p><strong>Full Page HTML</strong></p>
  
  <pre><code>@page
  @model RegisterModel
  
  @{
      ViewData["Title"] = "Sign Up";
  }
  
  &lt;div class="row"&gt;
      &lt;div class="col-md-6 offset-md-3"&gt;
          &lt;form asp-route-returnUrl="@Model.ReturnUrl" method="post"&gt;
              @if (ViewData.ModelState.ErrorCount &gt; 0)
              {
                  &lt;partial name="Partial/_ValidationErrorSummary" /&gt;
              }
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="Input.Email"&gt;Email&lt;/label&gt;
                  &lt;input asp-for="Input.Email" class="form-control" /&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="Input.Password"&gt;Password&lt;/label&gt;
                  &lt;input asp-for="Input.Password" type="password"class="form-control" /&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="Input.ConfirmPassword"&gt;Confirm Password&lt;/label&gt;
                  &lt;input asp-for="Input.ConfirmPassword" type="password" class="form-control" /&gt;
              &lt;/div&gt;
              &lt;button type="submit" class="btn btn-primary btn-lg btn-block"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>