tags:

views:

34

answers:

1

I have an ASP.NET MVC App, where I have interfaces for each viewmodel.

On a view called /Product/Details/50 I can edit details for product with id = 50.

I use strongly typed views, with the type being IProduct. I use Castle Windsor to do DI. When I post the edit form on the /Product/Details/50 view, the IProduct instance defaults to what it was set to on the HttpGet method called Details(int id) in the same controller.

I guess it's something to do with modelbinding. If I change the HttpPost method Details(IProduct product) to Details(Product product) it seems to work fine.

Any ideas?

+1  A: 

The issue here is that when we encounter IProduct, we don't know which type to instantiate. Our model binders don't integrate with your DI container. For the most part, I agree with Charlino, your domain models should probably be interface based, but the objects you model bind to ought to be dumb simple POCO objects which represent the values posted in the form.

Haacked
I've actually thought about dumping the interfaces, since I think the value I get is not worth the extra work.
MartinHN