title: AJAX 404 Error - Call to controller action .Net MVC
body: <p>I have a fairly simply .NET application with one page. </p>
  
  <p><img src="https://i.stack.imgur.com/NDVBf.png" alt="Structure of files][1"></p>
  
  <p>The code is meant to populate a table when run by calling the relevant controller to get the code and printing it out using a script. </p>
  
  <p>My controller:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web.Mvc;
  using techTest3.Models;  
  
  namespace techTest3.Controllers
  {
      public class HomeController : Controller
      {
      public ActionResult Index()
      {
          return View();
      }
  
      public JsonResult GetAllPeople()
      {
          TechTestEntities testTechObj = new TechTestEntities();
          var people = testTechObj.People.Select(x =&gt; new
          {
              Id = x.PersonId,
              Name = x.FirstName,
              Surname = x.LastName,
              Valid = x.Var1,
              Authorised = x.Var2
          }).ToList();
          return Json(people, JsonRequestBehavior.AllowGet);
      }  
  
  }
  }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>@{
  ViewBag.Title = " Showing Data Using jQuery Ajax Call JSON in ASP.NET MVC";
  } 
  &lt;h1&gt;Showing Data Using jQuery Ajax Call JSON in ASP.NET MVC &lt;/h1&gt; 
  
  &lt;div&gt;
      &lt;table id = "tblEmployee" class = "tblEmployee" &gt;
      &lt;thead&gt;
      &lt;!---&lt;img src = "~/Loading.gif" alt = "Loading" id = "imgLoading" class = "Load" /&gt;--&gt;
      &lt;/thead&gt; 
  
          &lt;tbody&gt;
           &lt;/tbody&gt; 
          &lt;/table&gt; 
          &lt;/div&gt; 
  
      &lt;script src="~/Scripts/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
      &lt;script type = "text/javascript" &gt;
      $(document).ready(function()
      {
          $("#tblEmployeetbodytr").remove();
          $.ajax
          ({
              type: 'POST',
              url: '@Url.Action("GetAllPeople")',
              dataType: 'json',
              data: {},
              success: function(data)
              {
              $("#imgLoading").hide();
              var items = '';
              var rows = "&lt;tr&gt;" +  
                      "&lt;th align='left' class='EmployeeTableTH'&gt;Employee ID&lt;/th&gt;&lt;th align='left' class='EmployeeTableTH'&gt;Name&lt;/th&gt;&lt;th align='left' class='EmployeeTableTH'&gt;Project Name&lt;/th&gt;&lt;th align='left' class='EmployeeTableTH'&gt;Manager Name&lt;/th&gt;&lt;th align='left' class='EmployeeTableTH'&gt;City&lt;/th&gt;" +  
                      "&lt;/tr&gt;";  
              $('#tblEmployeetbody'
  
  ).append(rows);
  
          $.each(data, function(i, item)  
          {  
              var rows = "&lt;tr&gt;" +  
                  "&lt;td class='EmployeeTableTD'&gt;" + item.Id + "&lt;/td&gt;" +  
                  "&lt;td class='EmployeeTableTD'&gt;" + item.FirstName + "&lt;/td&gt;" +  
                  "&lt;td class='EmployeeTableTD'&gt;" + item.LastName + "&lt;/td&gt;" +  
                  "&lt;td class='EmployeeTableTD'&gt;" + item.Var1 + "&lt;/td&gt;" +  
                  "&lt;td class='EmployeeTableTD'&gt;" + item.Var2 + "&lt;/td&gt;" +  
                  "&lt;/tr&gt;";  
              $('#tblEmployeetbody').append(rows);  
          });  
          },
          error: function(ex)
          {
          var r = jQuery.parseJSON(response.responseText);
          alert("Message: " + r.Message);
          }
          });
          return false;
          }); &lt;/script&gt; 
          &lt;style type = "text/css" &gt;
          &lt;/style&gt; 
  </code></pre>
  
  <p>Where TechTestEntities is the name of an edmx model that references a SQL database. </p>
  
  <p>When I debug the application, I get a 404 not found error. This happens with url: '&lt;%= Url.Action("GetAllPeople", "HomeController") %>', and url: '/Controllers/HomeController/GetAllPeople', and also url: '@Url.Action("/HomeController.cs/GetAllPeople"). </p>
  
  <p>Is there something obvious I'm missing? Please bear in mind I'm very new to AJAX and Javascript when answering.</p>