I have a form which posts these values:
survey[0].Key 75
survey[0].Value 4
survey[1].Key 76
survey[1].Value 4
I’m trying to use a default model binder to map it onto Dictionary type:
[HttpPost]
public ActionResult CompleteSurvey(Dictionary<int, int> answers)
{
...
}
but I get InvalidCastException: Specified cast is not valid.
Why??
For some strange reason when I removed “survey” and left iteration by itself (i.e. [0].Key) binding works fine.
I was basing my knowledge on this article:
http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx
which appears to be wrong then??? or does it refer to the previous versions of MVC???