Query string is too long - client sending empty string arrays

When using an ASP.NET ServiceStack project, without editing the web.config to permit long query strings a ServiceStack client will get a 404 if the query string is too long.

I came across this with some Query classes generated by the Ormlite T4 template against some rather large tables I had. Upon tracing the ServiceStack client I found all the string[] properties of the query class were being used to construct the query string, even through they are empty arrays.

I tracked it down to the GetQueryString method of UrlExtention.cs - it’s adding empty arrays to the query string.

I’ve created PR 1160 to address this - is there any problem with excluding empty arrays from the query string?

That wouldn’t reflect the true state of the DTO which is potentially a breaking change for anyone’s that detecting the difference. If you don’t want empty arrays sent the arrays should be set to null. Changing it for all URL’s isn’t the right place to put it.

Ok, fair enough.

How can I get the client generated class’s constructor to set all the properties to null? The generated C# client code sets the string arrays to a new string[].

I have large query classes and if the constructor could initialise those to null for me, it’d make the clients using my API a lot simpler.


I’ve made this an opt-in option in this commit.

1 Like