c# - Is the only way to use 'params' in a controller action to give it an array from JavaScript? -
i have method within controller:
[httpget] public jsonresult getpreference(params string[] settings) { // things related getting preferences return json(preferenceslist); }
is means pass parameters method ajax call array? there more graceful or elegant methods?
$.get(url, { settings: [color, rotation] });
i think should able along lines of this:
get /somecontroller/getpreference?settings%5b0%5d=first&settings%5b1%5d=second
(where %5b
[
, %5d
]
) or just
get /somecontroller/getpreference?settings=first&settings=second
see this post hanselman , this 1 haack.
the former useful if want use complex types rather string
or int
.
Comments
Post a Comment