Friday, September 16, 2011

ASP.NET MVC - An item with the same key has already been added

ASP.NET MVC having power full mechanism of model binding.Whatever data HTTP request carries from the client  side to server  ASP.NET MVC engine

takes the all keys and binds  the values to relevant properties .If the Model contains more than one key with same name ASP.NET throws this

exceptions .

Solution :

1.Identify the duplicated  properties in the model (May be your model inherited some base model which is having same key )
   and rename with unique name

 
2.Same name with different data types also you will face the exceptions.So change the data type If you have more than
    one property in model or base classes.