title: ASP.NET Core De-serialise IEnumerable<KeyValuePair<string, string>>> from Querystring
body: <p>I'm building a RESTful API in ASP.NET Core (3.0). Each controller has a method used to search domain objects which accepts a <em>List&lt;KeyValuePair&lt;string, string&gt;&gt;</em> as a querystring parameter defined like this:</p>
  
  <pre><code>    [HttpGet]
      [ProducesResponseType(200)]
      public ActionResult&lt;IEnumerable&lt;Service.Models.Asset&gt;&gt; Get(
          [FromQuery(Name = "criteria")] List&lt;KeyValuePair&lt;string, string&gt;&gt; criteria,
          [FromQuery] int? page = 0, 
          [FromQuery] int? size = null)
      {
          var dtoList = _assetService.SearchPaged(criteria, page, size);
          return Ok(dtoList);
      }
  </code></pre>
  
  <p>I'm passing the criteria as a JSON serialised string, the request URI is:</p>
  
  <pre><code>http://api/asset?criteria=[{"key":"uprn","value":"h1"},{"key":"uprn","value":"h2"}]&amp;page=0&amp;size=100
  </code></pre>
  
  <p>I can't get the controller to accept a value for the criteria parameter, the <em>criteria</em> list is always zero-length. I've tried URL encoding the text, makes no difference.</p>
  
  <p>If I change the parameter to a string, I can deserialize the parameter using JsonConvert successfully (same URI).</p>
  
  <pre><code>    [HttpGet]
      [ProducesResponseType(200)]
      public ActionResult&lt;IEnumerable&lt;Service.Models.Asset&gt;&gt; Get(
          [FromQuery(Name = "criteria")] string criteriaString,
          [FromQuery] int? page = 0, 
          [FromQuery] int? size = null)
      {
          var criteria = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;IEnumerable&lt;KeyValuePair&lt;string, string&gt;&gt;&gt;(criteriaString);
          var dtoList = _assetService.SearchPaged(criteria, page, size);
          return Ok(dtoList);
      }
  </code></pre>
  
  <p>I don't want to use model binding with a strongly typed parameter object because I have a generic parameter converter that builds an expression from the criteria list to apply to my EF DbSet. This is applied across a number of different controllers.</p>
  
  <p>Is this possible, or should I give up and stick with my string parameter and manage the de-serialization myself?</p>