title: An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters`
body: <p>I am creating a demo application in .net MVC.</p>
  
  <p>Below is the code snippet from my StudentController.</p>
  
  <pre><code>public ActionResult Edit(int studentId)
  {
      var std = studentList.Where(s =&gt; s.StudentId == studentId).FirstOrDefault();
      return View(std);
  }
  
  [HttpPost]
  public ActionResult Edit(Student std)
  {
      //write code to update student 
  
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>code snippet from RouteConfig : </p>
  
  <pre><code>routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
  routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  );
  </code></pre>
  
  <p>When I hit url <code>http://localhost:54977/student/Edit/1</code> I am getting following exception.</p>
  
  <p><code>The parameters dictionary contains a null entry for parameter 'studentId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'MVC1.Controllers.StudentController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  Parameter name: parameters</code>.</p>
  
  <p>But it works fine when I hit url <code>http://localhost:54976/student/Edit?StudentId=1</code>.</p>
  
  <p>I am new to .net MVC. Can anybody please suggest me on this.</p>