How can return a subset of a FormCollection with key/values in tact for those items with a certain prefix? I can do it for keys only but I need the keys and values.
Thanks
Try this (tested):
var form = Request.Form;
var prefix = "prefix";
var asDictionary = form.Cast<string>()
.Where(key => key.StartsWith(prefix))
.ToDictionary(key => key, key => form[key])
.ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With