Alternative to sending a comma separated parameter by query

I am trying to send the querystring parameter below, but I think that using a comma in querystring is invalid, so what is the best alternative to a comma separator for the path parameter?

<a href="/?path=1,2,3"></a> 

I do not want to send as <a href="/?path=1&path=2&path=3"></a> , which can be quite long.

+8
url query-string web
source share
6 answers

You can use %2C , which is a URL encoded value,.

+9
source share

The comma is allowed, it also has an uncoded form, since it is a reserved character.

Take a look at this section of RFC: RFC 3986 - 2.2. Reserved Characters

As I understand it, it depends only on how your server processes URLs containing a comma. Try and find out.

+4
source share

You can use the escaped value (or percent encoding if we are pedantic) "," or an unconditional character in accordance with RFC 3986 (- _. ~).

+2
source share

You can send it simply, I use lodash to collect product id

  vm.saleStartDate = vm.saleDateRange.startDate.toISOString(); vm.saleEndDate = vm.saleDateRange.endDate.toISOString(); vm.productIds = _.map(vm.selectedProducts, 'id').join(','); vm.iFrameURL = host + '/Reports/MonthWiseAvgSalesViewer.aspx?id=MonthWiseAvgSalesReport.rdlc&salesSD=' + vm.saleStartDate + '&salesED=' + vm.saleEndDate + '&prIds=' + vm.productIds 
0
source share

If you are sending integers, use spaces as a separator.

0
source share

You can use pipes "|" as a delimiter, but you will have to handle it on the server side. Not sure if it's worth the hassle though.

-one
source share

All Articles