2. May 2010 22:08
By
Roxin
In
asp.net mvc
I was working with asp.net mvc, and all of a sudden, on a form post I kept getting :
An item with the same key has already been added.
My model looked ok, the data being submited looked ok - I just couldn't figure it out. I wanted to debug into the MVC2 source (started to think select was broken :) ) ... which lead me down a path where I eventually reinstalled VS 2010 :) .
Eventually I came to my senses and started to think about it. I realized that my view Model had a base class - and then it hit me : in the base class I had a property "UserName" and in the child class "Username". Notice the small difference in caseing.
Since the model binder doesn't care about case - there you have it : a nice cryptic error.
Hth.
e01d2d88-843e-4dd5-b853-47636b002256|4|5.0
Tags: aspnet mvc