title: Jquery Datatable and Mysql Error: The value of the search cannot be null. If there's no search performed, provide an empty string.
body: <p>I am working on a project with ASP NET MVC5 and MYSQL.</p>
  
  <p>I am trying to create a Datatable to display the clients. But I am getting that error on the subject.</p>
  
  <p>At beggining I created controller, model, and view and I could not trace the error. At the end I only build the Controller and model and using POSTMAN I found somehting is not working.</p>
  
  <p>Here is my Model</p>
  
  <pre><code>using Newtonsoft.Json;
  using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  using System.Linq;
  using System.Web;
  
  namespace AseguradorasWeb.Models
  {
      [Table("clientes")]
      public class cliente
      {
  
          [Key]
          public int ID_Cliente { get; set; }
  
          [StringLength(60)]
          [Required(ErrorMessage = "El campo {0} es mandatorio")]
          [Index("NombreIndex")]
          [Display (Name = "Nombre")]
          public string NOM_Cliente { get; set; }
  
          [StringLength(60)]
          [Required(ErrorMessage = "El campo {0} es mandatorio")]
          [Index("ApellidoIndex")]
          [Display(Name = "Apellido")]
          public string APE_Cliente { get; set; }
  
          [StringLength(16)]
          [Display(Name = "RFC")]
          public string RFC_Cliente { get; set; }
  
          [StringLength(100)]
          [DataType(DataType.EmailAddress)]
          [Display(Name = "Email")]
          public string EMAIL_Cliente { get; set; }
  
          [StringLength(12)]
          [Display(Name = "Teléfono Casa")]
          public string TEL_CASA_Cliente { get; set; }
  
          [StringLength(12)]
          [Display(Name = "Teléfono Celular")]
          public string TEL_CEL_Cliente { get; set; }
  
          [StringLength(200)]
          [Display(Name = "Calle")]
          public string CALLE_NUM_Cliente { get; set; }
  
          [StringLength(50)]
          [Display(Name = "Colonia")]
          public string COLONIA_Cliente { get; set; }
  
          [StringLength(50)]
          [Display(Name = "Ciudad")]
          public string CIUDAD_Cliente { get; set; }
  
          [StringLength(30)]
          [Display(Name = "Estado")]
          public string EDO_Cliente { get; set; }
  
          [StringLength(200)]
          [Display(Name = "Dirección Oficina")]
          public string DIR_OFIC_Cliente { get; set; }
  
          [StringLength(12)]
          [Display(Name = "Teléfono Oficina")]
          public string TEL_OFIC_Cliente { get; set; }
  
          [StringLength(50)]
          [Display(Name = "Nombre Contacto")]
          public string NOM_CONTAC_Cliente { get; set; }
  
          [StringLength(12)]
          [Display(Name = "Teléfono Contacto")]
          public string TEL_CONTAC_Cliente { get; set; }
  
          [StringLength(12)]
          [Display(Name = "Celular Contacto")]
          public string CEL_CONTAC_Cliente { get; set; }
  
  
          [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
          [Display(Name = "Fecha Nacimiento")]
          public DateTime FEC_NAC_Cliente { get; set; }
  
          [StringLength(1)]
          [Display(Name = "Sexo")]
          public string SEXO_Cliente { get; set; }
  
          [StringLength(1)]
          [Display(Name = "Inactivo")]
          public string Inactivo_Cliente { get; set; }
  
          [DataType(DataType.MultilineText)]
          [Display(Name = "Observaciones")]
          public string Observaciones_Cliente { get; set; }
  
          [NotMapped]
          public string FullName { get { return string.Format("{0} {1}", NOM_Cliente ?? string.Empty, APE_Cliente ?? string.Empty).Trim(); } }
  
          [JsonIgnore]
          public virtual ICollection&lt;cliente_poliza&gt; cliente_poliza { get; set; }
  
      }
  }
  </code></pre>
  
  <p>Here is my controller and method I use to call it</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using AseguradorasWEB.Models;
  using AseguradorasWeb.Models;
  using DataTables.Mvc;
  using System.Linq.Dynamic;
  
  namespace AseguradorasWEB.Controllers
  {
      public class clientesController : Controller
      {
          private AseguradorasWEBContext db = new AseguradorasWEBContext();
  
  
          public ActionResult Get([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
          {
              IQueryable&lt;cliente&gt; query = db.clientes;
  
              var totalCount = query.Count();
  
              #region Filtering
              // Apply filters for searching
              if (requestModel.Search.Value != string.Empty)
              {
                  var value = requestModel.Search.Value.Trim();
                  query = query.Where(p =&gt; p.NOM_Cliente.Contains(value) ||
                                           p.APE_Cliente.Contains(value)
  
                                     );
              }
  
  
              var filteredCount = query.Count();
  
              #endregion Filtering
  
              #region Sorting
              // Sorting
              var sortedColumns = requestModel.Columns.GetSortedColumns();
              var orderByString = String.Empty;
  
              foreach (var column in sortedColumns)
              {
                  orderByString += orderByString != String.Empty ? "," : "";
                  orderByString += (column.Data) +
                    (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
              }
  
              query = query.OrderBy(orderByString == string.Empty ? "Nombre asc" : orderByString);
  
              #endregion Sorting
  
              // Paging
              query = query.Skip(requestModel.Start).Take(requestModel.Length);
  
              var data = query.Select(cliente =&gt; new
              {
                  Nombre = cliente.NOM_Cliente,
                  Apellido = cliente.APE_Cliente
              }).ToList();
  
              return Json(new DataTablesResponse
              (requestModel.Draw, data, filteredCount, totalCount),
                          JsonRequestBehavior.AllowGet);
          }
  </code></pre>
  
  <p>Whe I run the application and I use POSTMAN to call this method I am geeting the </p>
  
  <p>Error: The value of the search cannot be null. If there's no search performed, provide an empty string. </p>
  
  <p>Here is the full error:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;The value of the search cannot be null. If there's no search performed, provide an empty string.
              &lt;br&gt;Nombre del par&amp;#225;metro: value
          &lt;/title&gt;
          &lt;meta name="viewport" content="width=device-width" /&gt;
          &lt;style&gt;
           body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
           p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
           b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
           H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
           H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
           pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
           .marker {font-weight: bold; color: black;text-decoration: none;}
           .version {color: gray;}
           .error {margin-bottom: 10px;}
           .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
           @media screen and (max-width: 639px) {
            pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
           }
           @media screen and (max-width: 479px) {
            pre { width: 280px; }
           }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body bgcolor="white"&gt;
          &lt;span&gt;
              &lt;H1&gt;Error de servidor en la aplicación '/'.
                  &lt;hr width=100% size=1 color=silver&gt;
              &lt;/H1&gt;
              &lt;h2&gt;
                  &lt;i&gt;The value of the search cannot be null. If there's no search performed, provide an empty string.
                      &lt;br&gt;Nombre del par&amp;#225;metro: value
                  &lt;/i&gt;
              &lt;/h2&gt;
          &lt;/span&gt;
          &lt;font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "&gt;
              &lt;b&gt; Descripción: &lt;/b&gt;Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
              &lt;br&gt;
              &lt;br&gt;
              &lt;b&gt; Detalles de la excepción: &lt;/b&gt;System.ArgumentNullException: The value of the search cannot be null. If there's no search performed, provide an empty string.
              &lt;br&gt;Nombre del par&amp;#225;metro: value
              &lt;br&gt;
              &lt;br&gt;
              &lt;b&gt;Error de código fuente:&lt;/b&gt;
              &lt;br&gt;
              &lt;br&gt;
              &lt;table width=100% bgcolor="#ffffcc"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;code&gt;
  
  Se ha generado una excepci&amp;#243;n no controlada durante la ejecuci&amp;#243;n de la solicitud Web actual. La informaci&amp;#243;n sobre el origen y la ubicaci&amp;#243;n de la excepci&amp;#243;n pueden identificarse utilizando la excepci&amp;#243;n del seguimiento de la pila siguiente.&lt;/code&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br&gt;
              &lt;b&gt;Seguimiento de la pila:&lt;/b&gt;
              &lt;br&gt;
              &lt;br&gt;
              &lt;table width=100% bgcolor="#ffffcc"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;code&gt;
                              &lt;pre&gt;
  
  [ArgumentNullException: The value of the search cannot be null. If there&amp;#39;s no search performed, provide an empty string.
  Nombre del par&amp;#225;metro: value]
     DataTables.Mvc.Search..ctor(String value, Boolean isRegexValue) +97
     DataTables.Mvc.DataTablesBinder.Bind(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +300
     DataTables.Mvc.DataTablesBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +34
     System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +330
     System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
     System.Web.Mvc.Async.&amp;lt;&amp;gt;c__DisplayClass21.&amp;lt;BeginInvokeAction&amp;gt;b__19(AsyncCallback asyncCallback, Object asyncState) +743
     System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
     System.Web.Mvc.Controller.&amp;lt;BeginExecuteCore&amp;gt;b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
     System.Web.Mvc.Controller.&amp;lt;BeginExecute&amp;gt;b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
     System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
     System.Web.Mvc.MvcHandler.&amp;lt;BeginProcessRequest&amp;gt;b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
     System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
     System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
     System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
     System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +155
  &lt;/pre&gt;
                          &lt;/code&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br&gt;
              &lt;hr width=100% size=1 color=silver&gt;
              &lt;b&gt;Información de versión:&lt;/b&gt;&amp;nbsp;Versión de Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.6.1099.0
          &lt;/font&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;!-- 
  [ArgumentNullException]: The value of the search cannot be null. If there&amp;#39;s no search performed, provide an empty string.
  Nombre del par&amp;#225;metro: value
     en DataTables.Mvc.Search..ctor(String value, Boolean isRegexValue)
     en DataTables.Mvc.DataTablesBinder.Bind(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
     en DataTables.Mvc.DataTablesBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
     en System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
     en System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
     en System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__19(AsyncCallback asyncCallback, Object asyncState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     en System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)
     en System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     en System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)
     en System.Web.Mvc.Controller.&lt;BeginExecute&gt;b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     en System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
     en System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
     en System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
     en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
     en System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
     en System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
     en System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
     en System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
     en System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
  --&gt;
  </code></pre>
  
  <p>I am using visual studio 2015
  Datatables.mvc5 version 0.1.0
  jquery.datatables version 1.10.15</p>
  
  <p>Can you tell me what is wrong?</p>
  
  <p>Thanks</p>