title: How to render partial view inside a view in ASP.NET MVC
body: <p>I'm fairly new to ASP.NET MVC. I have to render Partial View inside a View. My Partial view has a model and an action method <em>MangeUsersInRole</em>. Anyways, I tried Html.RenderPartial, Html.Partial. One webpage, I'm experiencing an exception:</p>
  
  <p><a href="https://i.stack.imgur.com/FEFa1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FEFa1.png" alt="Exception"></a></p>
  
  <p>Heres my approach:
  View:</p>
  
  <pre><code>@model UserRole
  
  &lt;form method="post" action="/HKRole/AddUserToRole"&gt;
      &lt;div asp-validation-summary="ModelOnly" class="text-danger"&gt;&lt;/div&gt;
      &lt;input asp-for="@Model.Id" name="roleId" class="form-control" hidden /&gt;
  
      &lt;/div&gt;
  &lt;/form&gt;
  @Html.Partial("ManageUsersInRole");
  </code></pre>
  
  <p>Partial View:</p>
  
  <pre><code>@model List&lt;ManageUsersInRole&gt;
  &lt;table class="table"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;User Name&lt;/th&gt;
              &lt;th&gt;Email&lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              @for (int i = 0; i &lt; Model.Count; i++)
              {
                  &lt;td&gt;@Model[i].UserName&lt;/td&gt;
                  &lt;td&gt;@Model[i].UserEmail&lt;/td&gt;
  
              }
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>