1

I'm currently working on an ASP.NET Core Application, and we have a scenario where a certain entity type could have N number of additional text/number/boolean fields associate with it that is completely configurable by the user. We have a requirement to be able to search on these fields, however, the way the search is currently set up is for GET requests to produce a nice query string that can be shared and the back button works as you might expect rather than encountering issues with the back button on a POST request.

Since Working on this requirement, I have noticed that if N was to get to a pretty large number, we quickly end up exceeding the query string limit, and while I know that we can increase that limit, our query string currently comes out as something along the lines of

additionalField[0]=test&additionalField[1]=test&additionalField[2]=test&additionalField[3]=test&additionalField[4]=test&additionalField[5]=test&additionalField[6]=test&additionalField[7]=test&additionalField[8]=test..

So my question here is, is there a good resource to look at compressing this query string into something a little more compact? A good example I can think of is a game called Path of Exile has a trading website where people can list stuff for sale found here. If you type in some search parameters and hit search you'll notice how you get a concise url such as http://www.pathofexile.com/trade/search/Blight/aLBw05KHe <- that end part aLBw05KHe would be something that I would look to implement in my application.

Dan Scott
  • 554
  • 3
  • 10
  • Possible duplicate of [How to compress URL parameters](https://stackoverflow.com/questions/21802866/how-to-compress-url-parameters)? – DavidG Nov 25 '19 at 15:52
  • A simpler fix would be to rename your field from `additionalField` to something shorter like `a` which would make your example `a[0]=test&a[1]=test&a[2]=test&a[3]=test&a[4]=test&a[5]=test&a[6]=test&a[7]=test&a[8]=test..` – DavidG Nov 25 '19 at 15:58
  • Can you just do a POST instead of a GET? Then all the data could be passed in the body of the POST instead of GET query string params. – Casey Crookston Nov 25 '19 at 16:00
  • @DavidG that's not a bad shout, I could do that, however I think still you would end up with overflowing the max length of a querystring eventually if ``N`` was to get too long or one of the parameters was massive in length. @CaseyCrookston I could do a POST Request but then I run into issues with form resubmission and the results of the search would no longer be sharable as they would be a POST request that would provide no query string. – Dan Scott Nov 25 '19 at 16:05
  • You really won't be able to compress it much I suspect, just go with a POST. – DavidG Nov 25 '19 at 16:06

0 Answers0