title: Html Helper 'Action' is Undefined, Asp.NET Core 2.2
body: <p>I am brand new to ASP.NET Core MVC. I'll preface this question by saying I have read the other similar questions, but they weren't exactly the same problem I am having.</p>
  <p>I am trying to implement a dynamic left side navigation, where each of the buttons are loaded from my database.</p>
  <p>When I call <code>@Html.Action(&quot;NavMenu&quot;, &quot;Nav&quot;)</code> in my &quot;_Layout.cshtml&quot; I get the error</p>
  <blockquote>
  <p>Error CS1929<br />
  'IHtmlHelper' does not contain a definition for 'Action' and the best extension method overload 'UrlHelperExtensions.Action(IUrlHelper, string, object)' requires a receiver of type 'IUrlHelper'</p>
  </blockquote>
  <p>One of the other similar questions led me to adding <code>@using System.Web.Mvc.Html</code> to the top of my &quot;_ViewImports&quot; and that leads to the error:</p>
  <blockquote>
  <p>CS7069: Reference to type 'RouteValueDictionary' Claims it is defined in 'System.Web', but it could not be found</p>
  </blockquote>
  <p>Also the answer said <code>@html.Action()</code> should be built in to Core 2.0</p>
  <p>using <code>@await Html.PartialAsync(&quot;_SideNav&quot;)</code> only works on my Index view, as that view has <code>@model IEnumerable&lt;HSCWebApp.Models.HSCTable&gt;</code> but my other views need <code>@model HSCWebApp.Models.HSCTable</code>, which causes &quot;_SideNav&quot; to crash</p>
  <p>I am 100% open to other ways to implement this.</p>
  <p>In NuGet I have installed:</p>
  <ul>
  <li>Entity Framework</li>
  <li>Microsoft.AspNet.Mvc</li>
  <li>Microsoft.AspNetCore.App</li>
  <li>Microsoft.NETCore.App</li>
  </ul>
  <p>EDIT:</p>
  <p>I am also getting these warnings during build:</p>
  <blockquote>
  <p>Warning   NU1701  Package 'Microsoft.AspNet.Mvc 5.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.</p>
  </blockquote>
  <p>along with ones for Entity Framework, AspNet.Razor AspNet.Webpages</p>
  <p>Would these warnings affect my references in some way?</p>
  <hr />
  <p>Here are the files:</p>
  <p>Controller: (&quot;NavController.cs&quot;)</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Diagnostics;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using HSCWebApp.Models;
  using Microsoft.EntityFrameworkCore;
  
  namespace HSCWebApp.Controllers
  {
      public class NavController : Controller
      {
  
          private readonly HSCWebAppContext _context;
  
          public NavController(HSCWebAppContext context)
          {
              _context = context;
          }
          public ActionResult NavMenu()
              {
              
              NavViewModel nav = new NavViewModel();
              List&lt;NavViewModel&gt; navList = new List&lt;NavViewModel&gt;();
  
              var items = from n in _context.HSCTable select n;
              List&lt;HSCTable&gt; tableList = items.ToList&lt;HSCTable&gt;();
  
  
              for (int i = 0; i &lt; tableList.Count(); i++)
              {
                  nav.Id = tableList[i].ID;
                  nav.DepartmentName = tableList[i].DepartmentName;
                  nav.sel = tableList[i].sel;
                  navList.Add(nav);
              }
  
  
              //var movies = from m in _context.Movie select m;
              //IEnumerable&lt;NavViewModel&gt; en = navList;
              //IEnumerable&lt;HSCTable&gt; en = tableList;
  
              return PartialView(&quot;_SideNav&quot;, tableList);
              }
          
      }
  }
  </code></pre>
  <p>Model: (&quot;NavViewModel.cs&quot;)</p>
  <pre><code>    using System.ComponentModel.DataAnnotations.Schema;
      namespace HSCWebApp.Models
      {
          [Table(&quot;HSCTable&quot;)]
          public class NavViewModel
          {
              public NavViewModel(){
                  int Id = this.Id;
                  string DepartmentName = this.DepartmentName;
                  string sel = this.sel;
                  }
              public int Id { get; set; }
              public string DepartmentName { get; set; }
              public string sel { get; set; }
          }
      }
  </code></pre>
  <p>View: (&quot;_SideNav.cshtml&quot;)</p>
  <pre><code>@model IEnumerable&lt;HSCWebApp.Models.HSCTable&gt;
  @using System;
  @using System.Collections;
  @using System.Linq;
  
  @{
  
      List&lt;List&lt;string&gt;&gt; navButtons = new List&lt;List&lt;string&gt;&gt;();
      int listIndex = 0;
      int INITIAL = 0;
  
      navButtons.Add(new List&lt;string&gt;());
      navButtons[listIndex].Add(&quot;&quot;);
  
  }
  
  
  &lt;body&gt;
      &lt;div class=&quot;sidenav&quot;&gt;
          @{
  
              foreach (var item in Model)
              {
  
                  if (navButtons[listIndex][INITIAL].Equals(null) 
                      || navButtons[listIndex][INITIAL].Equals(&quot;&quot;)) 
                  {
                      // if the list of lists is empty, add the department name
                      //initialize the list with with the department name
                      navButtons[listIndex][INITIAL] = item.DepartmentName;
                      //add the current select
                      navButtons[listIndex].Add(item.sel);
                  }
                  else if (navButtons[listIndex][INITIAL].Equals(item.DepartmentName)) 
                  {
                      // if the current item's department name is the same 
                      // is the current list's department name, 
                      // add it's selectn
                      navButtons[listIndex].Add(item.sel);
                  }
                  else if (!item.DepartmentName.Equals(navButtons[listIndex][INITIAL]))
                  {
                      // if the current item's department name 
                      // is not the same as the initial of this list, 
                      // create new list
                      navButtons.Add(new List&lt;string&gt;());
                      listIndex++;
                      navButtons[listIndex].Add(item.DepartmentName);
                      navButtons[listIndex].Add(item.sel);
                  }
              }
  
  
  
  
  
              for (int i = 0; i &lt; navButtons.Count; i++)
              {
                  &lt;button class=&quot;accordion&quot;
                          onclick=&quot;openAccordion(this)&quot;&gt;
                       @navButtons[i][INITIAL]
                  &lt;/button&gt;
                  &lt;div class=&quot;tab&quot;&gt;
                      @for (int j = 1; j &lt; navButtons[i].Count; j++)
                      {
                          &lt;a class=&quot;tabLinks NoPrint&quot; 
                             onclick=&quot;openTab(this)&quot; 
                             asp-action=&quot;Details&quot; 
                             asp-route-id=&quot;@navButtons[i][j]&quot;&gt;
                                @navButtons[i][j].ToString() 
                          &lt;/a&gt;
                      }
                  &lt;/div&gt;
              }
  
            //          @Url.Action(&quot;Details&quot;, &quot;HSCTables&quot;, new { id = 1 })
            //onclick = &quot;location.href='@Url.Action(&quot;Details&quot;,&quot;HSCTables&quot;, new { id = 1 })
  
          }
  
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  <p>Thank you very much for your time.</p>