In my querystring I get a bunch of parameter names and values.
As I understand I should be using the built in asp.net mvc function TryUpdateModel(modelInstance).
It seems though that it is not working as I'm expecting. My parameter names do defer in capitalization. Is this a problem?
Furthermore I have some custom types that need a specific method to do some business logic checking to convert a string into an instance of this class. Where should i put this logic?
views:
450answers:
1Steve Sanderson has nearly a whole chapter on model binding in his recently published book Pro ASP.NET MVC Framework (Apress) which I really recommend.
Can you post some specific code that you are having trouble with?
I don't think capitalization matters, but I could be wrong.
If the DefaultModelBinder doesn't work on your complex model types, you may need to derive your own custom model binder. Here is an extremely simplified example of a custom model binder. I'm pretty sure the DefaultModelBinder could handle the simple Customer object defined here: Simple custom model binder
Here is another article with a few tips on model binding and building a custom model binder: 6 Tips for ASP.NET MVC Model Binding and Iterating on an ASP.NET MVC Model Binder.
I still recommend the Steve Sanderson book mentioned above because it has the best explanation I've seen so far and has a more complicated example for a custom model binder (to an XDocument).