ASP.net MVC – Model binding excludes class fields?

Is this by design?

Yes, only properties with public getter/setters work with the default model binder.

besides changing the fields to properties – any options here?

That’s what you should do as you should be using view models anyway. And view models are specifically designed for the views. So changing the fields to properties is the correct way to do. Now if you don’t follow good practices and try to use your domain models as input/output to actions then you will have to write a custom model binder that works with fields. It will be a lot of work though.

Leave a Comment