I have an application that has list of ID's as a part of the URL but soon the number of ID's are going to increase drastically. What is the best method to have a big number of ID's in the URL. The ID's can go up to 200 or more at a time.
Asked
Active
Viewed 221 times
1 Answers
0
You could encode your ID array in a string (JSON is an easy format for that) and transmit it as a single variable via POST.
Simple GET Parameters or even the URL itself has some limits on it's length that can no be avoided. Most Webservers also have security Filters in place that wont accept more than a certain number of Parameters. (Suhosin)
See:
-
I wish, I have to use the ID's in the URL only as this is a web service as well. And the client is extracting ID's from the URL itself. – Nick Div Jul 21 '14 at 15:11
-
Then you wont be able to send more than a couple of IDs. Maybe split them and call your webservice several times? – ToBe Jul 21 '14 at 15:21
-
Why not, is there a limitation on the number of characters in the URL, I know IE has 2048 but that is enough for me. I just want to make sure that I am using the best available method to re-write my URL – Nick Div Jul 21 '14 at 15:23
-
Webservers have limitations and also many services like PHP have them. Usually there are additional security filters which further limit the number of parameters. – ToBe Jul 21 '14 at 15:25
-
Webserver is not a problem as it is private. But what security filters? at what layer are they present. – Nick Div Jul 21 '14 at 15:27
-
A private webserver still has limits. Not all of them can simply removed by configuration. Have you checked PHP.ini configuration and a possible suhosin configuration? – ToBe Jul 21 '14 at 15:29
-
Ok, I just tried it and it worked perfectly fine with 200 ID's so there is no issue with the number of ID's I am planning to forward. Now the only issue is that how do I write it in the most optimized way. That doesn't look so absurd to the user. – Nick Div Jul 21 '14 at 15:31
-
If it's all numeric ids, just make a comma seperated list? – ToBe Jul 21 '14 at 15:32
-
Already doing that and somehow it doesn't feel correct. I am sure that I am missing something. There has to be another way a better way to do this. – Nick Div Jul 21 '14 at 15:35
-
Bordering on taste here, but having a one-letter seperator in a list of ids that can not be part of the ids themselfes is probably as short and readable as you can get. (while not packing stuff zip like) – ToBe Jul 21 '14 at 15:37
-
Probably.. lets see how the search goes. – Nick Div Jul 21 '14 at 15:54