I’ve written a model binder and a value provider for asp.net core.

The project

I had a problem with query string length in my GET requests. Array were being passed in the queries, like this:

public class SomeRequest
	public int[] SomeNumbers{ get; set; }

And this led to some really really long query strings


Which isn’t great. There are often limits to how long a query string can get before stuff breaks. And, besides, this query string is ugly.

One option is to just switch to POST and start using request bodies instead. But I thought I’d do some things first to cut down length.

First, here’s what my Delimiting Query String Value Provider does. It allows for a less verbose style of array syntax in queries.


Second, here’s what my AliasModelBinder does. It allows use of alternative property names in queries, without actually having to rename the properties.


And, of couse, if we’re playing URL golf, here is the combination:


If you have similar problems with long query strings, or would otherwise like to use one of these tools on your project, you can check out my ASP.NET Core model binding repository, and follow links to the nuget packages on nuget.org. There’s a lot more detail there for anyone who wants to use this code in their web projects.

What did I learn?

  • I learnt a lot about asp.net core and it’s pipeline between receiving requests and passing it to the controllers.
  • This was also the first project I set up on appveyor.