title: How to design an MVC5 Global Dropdown List feature in Layout.cshtml
body: <p>I tried to make a partial view of a  dropdown list to load data using ViewModel as context.categories.tolist(). and then Render the partial view on the layout page! but render page giving an error! asking the same ViewModel to pass! Have any idea how to design a dropdownlist on the layout page without using @model ViewModel !!?</p>
  <pre><code>public ActionResult CategoryDropDown()
          {
              HomeViewModel model = new HomeViewModel();
  
              model.AllCategory = CategoriesService.Instance.allCategory();
            //getting category list from database
  
              return PartialView(model);
          }
  </code></pre>
  <p><strong>Views/Shared/_Layout.cshtml</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;header&gt;
  all the headers link///
  &lt;/header&gt;
  &lt;section&gt;
  @if (Model != null &amp;&amp; Model.AllCategory.Count &gt; 0)
  {
      &lt;div class=&quot;col-lg-3&quot;&gt;
          &lt;div class=&quot;hero__categories&quot;&gt;
              &lt;div class=&quot;hero__categories__all&quot;&gt;
                  &lt;i class=&quot;fa fa-bars&quot;&gt;&lt;/i&gt;
                  &lt;span&gt;All departments&lt;/span&gt;
              &lt;/div&gt;
              &lt;ul&gt;
                  @foreach (var category in Model.AllCategory)
                  {
                      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;@category.Name&lt;/a&gt;&lt;/li&gt;
                  }
  
  
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  &lt;/section&gt;
  Renderbody()
  
  
     
      @RenderSection(&quot;scripts&quot;, required: false)
  
  &lt;/html&gt;
  ~~
  </code></pre>