Passing array values in an HTTP request in .NET

There isn't really a standard, but what you are using is the closest to it.

However, the values are actually not sent as a comma separated string, they are sent as separate values with the same name. The form data from your example will look like this:

user=Aaron&user=Bobby&user=Jimmy&user=Kelly&user=Simon&user=TJ

You can read the values as an array directly like this:

string[] users = context.Request.Form.GetValues("user");

If you use Form["user"] it will concatenate the values for you and you have to split them again. This is just a waste of time, and it also breaks if any of the values contains a comma.


If you are using checkboxes or a multi-select list box, then a comma-separated set of values is what you get automatically from html. What you are doing is perfectly fine. If you generate an array in your javascript in some other way, you could generate comma-separated string and assign it to a hidden field, and use split() on the server in the same way. XML is certainly another option, but it seems to complex to me if all you want to do is pass a simple array of numbers or short strings. (Of course, if the string values you need to pass contain commas, this would screw up your simple plan.)