title: I am receiving a Server error on on the controller on my ASP.NET MVC app
body: <p>I have an ASP.NET MVC application that I have created. The data displays fine however I get an error which you can see below:</p>
  
  <p><a href="https://i.stack.imgur.com/jTWpK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jTWpK.png" alt="enter image description here"></a> </p>
  
  <p>I have created the views and controllers fine however on 2 out of the 5 views / index there is an issue when performing a search via the controller I get an error. </p>
  
  <p>Below is the search functionality I have added to the controller </p>
  
  <pre><code> public AppSupportEntities db = new AppSupportEntities();
  
          // GET: Servers
          public ActionResult Index(string searchBy, string search)
          {
              if (searchBy == "NAME")
              {
                  return View(db.Servers.Where(x =&gt; x.NAME.StartsWith(search) || search == null).ToList());
              }
              else
              {
                  return View(db.Servers.Where(x =&gt; x.DESCRIPTION.StartsWith(search) || search == null).ToList());
              }
          }
  </code></pre>
  
  <p>This is the search functionality added to the index page on the view </p>
  
  <pre><code>@model IEnumerable&lt;ADSTrepo.Models.Server&gt;
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Server List&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  
  &lt;p&gt;
      @using (Html.BeginForm("Index", "Server", FormMethod.Get))
      {
          &lt;b&gt;Search By:&lt;/b&gt; @Html.RadioButton("searchBy", "Name") &lt;text&gt;Name&lt;/text&gt;
          @Html.RadioButton("searchBy", "Description") &lt;text&gt;Description&lt;/text&gt;
          @Html.TextBox("Search")&lt;input type="submit" value="Search" /&gt;
      }
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.NAME)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.DESCRIPTION)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      @if (Model.Count() == 0)
      {
          &lt;tr&gt;
  
              &lt;td colspan="2"&gt; No rows match the search criteria please try again&lt;/td&gt;
  
          &lt;/tr&gt;
      }
  
      else
      {
          foreach (var item in Model)
          {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.NAME)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.DESCRIPTION)
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                      @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                      @Html.ActionLink("Delete", "Delete", new { id = item.ID })
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
      }
  &lt;/table&gt;
  </code></pre>
  
  <p>Any help is greatly appreciated I must be missing something obvious however the views and controllers seem fine and the same as the others that are working </p>