title: MVC Error: model item of type 'System.Collections.Generic.IEnumerable`1 required
body: <p>I'm doing some modifications to a system, and I've run into an exception that I was hoping someone could help with?? The error I'm getting is the following:</p>
  
  <blockquote>
    <p>Exception Details:
    System.InvalidOperationException: The
    model item passed into the dictionary
    is of type
    'System.Collections.Generic.List<code>1[System.String]',
    but this dictionary requires a model
    item of type
    'System.Collections.Generic.IEnumerable</code>1[MyApp.Data.aspnet_Users]'.</p>
  </blockquote>
  
  <p>Basically what I want to do is display a list of Inactive users. Here is the controller I've written for that:</p>
  
  <pre><code>public ActionResult InactiveUsers()
          {
              using (ModelContainer ctn = new ModelContainer())
              {
                  aspnet_Users users = new aspnet_Users();
  
                  DateTime duration = DateTime.Now.AddDays(-3);
  
                  var inactive = from usrs in ctn.aspnet_Users
                      where usrs.LastActivityDate &lt;= duration
                      orderby usrs.LastActivityDate ascending
                      select usrs.UserName;
  
                  return View(inactive.ToList());
              }
  
          }
  </code></pre>
  
  <p>From here then I added a partial view. Here is the code for it if anyone is interested. Just the usual Add View --> List. </p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;MyApp.Data.aspnet_Users&gt;&gt;" %&gt;
  
      &lt;table&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;/th&gt;
              &lt;th&gt;
                  ApplicationId
              &lt;/th&gt;
              &lt;th&gt;
                  UserId
              &lt;/th&gt;
              &lt;th&gt;
                  UserName
              &lt;/th&gt;
              &lt;th&gt;
                  LoweredUserName
              &lt;/th&gt;
              &lt;th&gt;
                  MobileAlias
              &lt;/th&gt;
              &lt;th&gt;
                  IsAnonymous
              &lt;/th&gt;
              &lt;th&gt;
                  LastActivityDate
              &lt;/th&gt;
          &lt;/tr&gt;
  
      &lt;% foreach (var item in Model) { %&gt;
  
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;%: Html.ActionLink("Edit", "Edit", new { id=item.UserId }) %&gt; |
                  &lt;%: Html.ActionLink("Details", "Details", new { id=item.UserId })%&gt; |
                  &lt;%: Html.ActionLink("Delete", "Delete", new { id=item.UserId })%&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.ApplicationId %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.UserId %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.UserName %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.LoweredUserName %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.MobileAlias %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: item.IsAnonymous %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: String.Format("{0:g}", item.LastActivityDate) %&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;% } %&gt;
  
      &lt;/table&gt;
  
      &lt;p&gt;
          &lt;%: Html.ActionLink("Create New", "Create") %&gt;
      &lt;/p&gt;
  </code></pre>
  
  <p>And for completeness here is the Index page where I render the partial:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Administrator.Master" Inherits="System.Web.Mvc.ViewPage&lt;dynamic&gt;" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Index
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Index&lt;/h2&gt;
  
      &lt;% Html.RenderAction("InactiveUsers"); %&gt;
  
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server"&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>If anyone has any advice I'd be very grateful :)</p>