title: MVC - Failed to load resource: the server responded with a status of 500 (Internal Server Error)
body: <p>I am having a problem with some Ajax code I wrote for my MVC 5 project, I am trying to implement a search bar for my table using ajax but I am running into this error "Failed to load resource: the server responded with a status of 500 (Internal Server Error)".</p>
  
  <p>This is my Partial View code which includes the JavaScript Ajax code:</p>
  
  <pre><code>@model IEnumerable&lt;ToDo.Models.Venue&gt;   
  
  @*Search Box*@
  @using (Html.BeginForm())
  {
      &lt;p&gt;
          &lt;input type="text" class="form-control" id="txtSearch"&gt;
          &lt;span class="btn btn-sm btn-warning" id="btnCustomerInc" onclick="VenueSearch();"&gt;Search&lt;/span&gt;
      &lt;/p&gt;
  }
  
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.VenueName)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.VenueType)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.VenueTown)
          &lt;/th&gt;
          &lt;th&gt;
              @*blank*@
          &lt;/th&gt;
      &lt;/tr&gt;
  
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.VenueName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.VenueType)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.VenueTown)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.ActionLink("Details", "Details", new { id = item.VenueID }, new { @class = "btn btn-primary" })
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  
  &lt;script&gt;
      function VenueSearch() {
          console.log("Venue Search function hit");
  
          var search = document.getElementById("txtSearch").value;
          console.log(search);
  
          $.ajax({
              type: "GET",
              url: '@Url.Action("VenuesTablePartialView", "Venues")',
              data: { searchString: search },
              success: function (data) {
  
                  $('#VenueTable').html(data);
                  $('#VenueTable').fadeIn("fast")
  
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is my controller action for the partial view:</p>
  
  <pre><code> [ChildActionOnly]
          public ActionResult VenuesTablePartialView(string searchString)
          {    
              var venues = from v in db.Venues
                           select v;
  
              //Search
              if (!String.IsNullOrEmpty(searchString))
              {
                  venues = venues.Where(v =&gt; v.VenueName.ToUpper().Contains(searchString.ToUpper()));
              }
  
  
              return PartialView("_VenuesTable", venues.ToList());
          }
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TMGSp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMGSp.png" alt="This image shows the error and the console messages"></a></p>