views:

789

answers:

6

I need to accept a list of file names in a query string. ie:

http://someSite/someApp/myUtil.ashx?files=file1.txt|file2.bmp|file3.doc

Do you have any recommendations on what delimiter to use?

A: 

I think I would consider using commas or semicolons.

nan
+1  A: 

I've always used double pipes "||". I don't have any good evidence to back up why this is a good choice other than 10 years of web programming and it's never been an issue.

Rick Hochstetler
+1  A: 

I would recommend making each file it's own query parameter i.e.

myUtil.ashx?file1=file1.txt&file2=file2.bmp&file3=file3.doc

This way you can just use standard query parsing and loop

Harry
+1 standard way of doing multiple values
bobince
A: 

Do you need to list the filenames as a string? Most languages accepts arrays in the querystring so you could write it like

http://someSite/someApp/myUtil.ashx?files[]=file1.txt&files[]=file2.bmp&files[]=file3.doc

If it doesn't, or you can't use for some other reason, you should stick to a delimiter that is either not allowed or unusual in a filename. Pipe (|) is a good one, otherwise you could urlencode an invisible character since they are quite easy to use in coding, but harder to actually include in a filename.

I usually use arrays when possible and pipe otherwise.

Jimmy Stenke
+4  A: 

If they're filenames, a good choice would be a character which is disallowed in filenames. Suggestions so far included , | & which are generally allowed. / on the other hand is generally not allowed, not even on Windows. It is allowed in URIs, and it has no special meaning in query strings.

MSalters