title: Html.ValidationSummary Not Populating with Custom Errors ASP.NET MVC Razor Page
body: <p>I'm fairly new to MVC, I need to create a custom error that would fire if the user does not select a category. However the Html.ValidationSummary is not populating when a product without categories is created. Instead the view is returned and shown on the browser without the validation summary being populated. Please see below, I've have copied the relevant code over.<br>
  CSHTML CODE</p>
  
  <pre><code>@Html.ValidationSummary(false, "", new { @class = "text-danger" })
  </code></pre>
  
  <p>CONTROLLER CODE</p>
  
  <pre><code>if (!model.HasCategories)
  {
       ModelState.AddModelError(string.Empty, "A category is required.");
  }
  
  if(!ModelState.IsValid()) {
      return RedirectToAction("addEditProduct", new { id = model.P.ID});
  }
  </code></pre>