title: ASP.Net MVC - Pass parameter from view using a href
body: <p>I currently have the following link that navigates from one view to another:</p>
  
  <pre><code>"&lt;td class='EmployeeTableTD'&gt;&lt;a href='personDetails'&gt;" + item.Name + " " + item.Surname + "&lt;/a&gt;&lt;/td&gt;" +
  </code></pre>
  
  <p>The table is dynamically created in Javascript and gets the data (item) from an ADO model.</p>
  
  <p>I want to attach parameters to pass them through to the controller and then to the view of the next screen. </p>
  
  <p>I have tried taking the usual </p>
  
  <pre><code>'personDetails?myParameter=' + item.Name
  </code></pre>
  
  <p>type of method, but this caused a 404 error. I also tried inserting a @HTML.ActionLink into the code, but this is also problematic as the intellisense does not recognise 'item' when trying to set the parameters. </p>
  
  <p>Is there a way I can pass dynamic parameters from this view link to the next controller/view?</p>
  
  <p>Controller:</p>
  
  <pre><code>using System;
  ...
  namespace techTest4.Controllers
  {
      public class HomeController : Controller
      {
          private TechTestEntities techContext = new TechTestEntities();
  
          public ActionResult personDetails()
          {
              return View();
          }
  
          public ActionResult Index()
          {
              return View();
          }
  </code></pre>
  
  <p>So my navigation correctly goes to 'Home/personDetails' and the 'personDetails.cshtml' view (which has little in it yet, but needs to output the parameters passed). It arguably should navigate to 'Home/personDetailsController/{someIndexMethod}' where the set up of the next page would be handled. </p>
  
  <p>Config:</p>
  
  <pre><code>routes.MapRoute(
                  name: "Details",
                  url: "PeopleDetails/{action}/{id}",
                  defaults: new
                  {
                      controller = "PeopleDetails",
                      action = "All",
                      id = UrlParameter.Optional
                  }
              ); 
  </code></pre>