title: ASP.NET MVC 5 jQuery UI autocomplete search box
body: <p>I am trying to create search box which show results when user is typing in.</p>
  
  <p>I have the following in my partial view:</p>
  
  <pre><code>@Html.EditorFor(m =&gt; m.CategoryName, new { htmlAttributes = new { @id = "inputCat", @class = "form-control", @placeholder = "Enter category name...", @spellcheck = "true" } })
  </code></pre>
  
  <p>In my main view where I load the partial view I have:</p>
  
  <pre><code>$('#inputCat').autocomplete({
      source: 'Editor/SearchCategory'
  });
  </code></pre>
  
  <p>Here is my controller action:</p>
  
  <pre><code>public ActionResult SearchCategory(string term)
  {
      ApplicationDbContext db = new ApplicationDbContext();
      return Json(db.Categories.Where(cat =&gt; cat.CategoryName.StartsWith(term)), JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>When I type in the input field in the browser console I get this error:</p>
  
  <pre><code>GET http://localhost:port/Editor/SearchCategory?term=s 500 (Internal Server Error)
  </code></pre>
  
  <p>I cannot understand where is the problem.
  Any help will be appreciated.
  Thanks in advance.</p>