asp.net-mvcformcollection

asp.net-mvc get a dictionary in post action or how to transform FormCollection into a dictionary


anybody knows how to transform the FormCollection into a IDictionary or how to get a IDictionary in the post action ?


Solution

  • This is just an equivalent of Omnu's code, but it seems more elegant to me:

    Dictionary<string, string> form = formCollection.AllKeys.ToDictionary(k => k, v => formCollection[v]);