title: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1 .
body: <p>Welcome,</p>
  <p>I have several pictures, when I click on one it should take me to another window of this picture.
  But this does not happen, but I get this window with this error message:</p>
  <blockquote>
  <p>The model item passed into the dictionary is of type
  'System.Collections.Generic.List`1[FirstProject.Models.student]', but
  this dictionary requires a model item</p>
  </blockquote>
  <p>I will put the codes related to the problem:</p>
  <p><em><strong>HomeController</strong></em></p>
  <pre><code>using FirstProject.Models;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  
  namespace FirstProject.Controllers
  {
      public class HomeController : Controller
      {
          level_8_coursesEntities db = new level_8_coursesEntities();
          public ActionResult Index()
          {
              List&lt;level_8_courses&gt; list = db.level_8_courses.ToList();
              return View(list);
          }
          public ActionResult Numberofstudents()
          {
              List&lt;level_8_courses&gt; list = db.level_8_courses.ToList();
              return View(list);
          }
  
          public ActionResult Students(int? id)
          {
              List&lt;student&gt; studentlist = null;
              if (id.HasValue)
              {
                  studentlist = db.students.Where(x =&gt; x.corId == id).ToList();
              }
              else
              {
                  // Set the `studentlist` to some default value when `id` doesn't defined or not a number.
                  studentlist = null;
      }
              return View(studentlist);
          }
  </code></pre>
  <p><em><strong>Number of students.chtml</strong></em></p>
  <pre><code>    @{
          ViewBag.Title = &quot;Numberofstudents&quot;;
      }
      
      @using FirstProject.Models;
      @model List&lt;level_8_courses&gt;
  
  &lt;div class=&quot;container&quot;&gt;
      &lt;section class=&quot;page-section portfolio&quot; id=&quot;portfolio&quot;&gt;
          &lt;div class=&quot;container&quot;&gt;
              &lt;!-- Portfolio Section Heading--&gt;
              &lt;h2 class=&quot;page-section-heading text-center text-uppercase text-secondary mb-0&quot;&gt;Numberofstudents&lt;/h2&gt;
              &lt;!-- Icon Divider--&gt;
              &lt;div class=&quot;divider-custom&quot;&gt;
                  &lt;div class=&quot;divider-custom-line&quot;&gt;&lt;/div&gt;
                  &lt;div class=&quot;divider-custom-icon&quot;&gt;&lt;i class=&quot;fas fa-star&quot;&gt;&lt;/i&gt;&lt;/div&gt;
                  &lt;div class=&quot;divider-custom-line&quot;&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- Portfolio Grid Items--&gt;
              &lt;div class=&quot;row justify-content-center&quot;&gt;
                  &lt;!-- Portfolio Item 1  data-bs-target=&quot;#portfolioModal&quot; --&gt;
                  @foreach (var item in Model)
                  {
                      
                          &lt;div class=&quot;col-md-6 col-lg-4 mb-5&quot;&gt;
                              &lt;a href=&quot;/Home/students/@item.Id&quot;&gt;
                                  &lt;div class=&quot;portfolio-item mx-auto&quot; data-bs-toggle=&quot;modal&quot;&gt;
                                      &lt;div class=&quot;portfolio-item-caption d-flex align-items-center justify-content-center h-100 w-100&quot;&gt;
                                          &lt;div class=&quot;portfolio-item-caption-content text-center text-white&quot;&gt;&lt;i class=&quot;fas fa-plus fa-3x&quot;&gt;&lt;/i&gt;&lt;/div&gt;
                                      &lt;/div&gt;
  
                                      &lt;img class=&quot;img-fluid&quot; style=&quot;height:100px;width:100px&quot; src=&quot;@item.photo&quot; alt=&quot;&quot; /&gt;
                                  &lt;/div&gt;
                              &lt;/a&gt;
                              &lt;div style=&quot;text-align:center&quot;&gt;
                                  &lt;h5&gt;@item.corName&lt;/h5&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                  
                  }
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  &lt;/div&gt;
  </code></pre>
  <p><em><strong>Students.chtml</strong></em></p>
  <pre><code>@using FirstProject.Models;
  @model List&lt;student&gt;
  
  &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;row&quot;&gt;
          @foreach (var item in Model)
          {
              &lt;div class=&quot;card col-sm-6&quot;&gt;
                  &lt;div class=&quot;card&quot; style=&quot;width: 18rem;&quot;&gt;
                      &lt;img class=&quot;card-img-top&quot; src=&quot;...&quot; alt=&quot;Card image cap&quot;&gt;
                      &lt;div class=&quot;card-body&quot;&gt;
                          &lt;h5 class=&quot;card-title&quot;&gt;@item.sName&lt;/h5&gt;
                          &lt;p class=&quot;card-text&quot;&gt;@item.sEmail&lt;/p&gt;
                        
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          }
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  <p>Thanks</p>