A little clarification
GET and POST controller actions can easily use whatever types they need. We are not really talking about models here. A model is a collection of classes / types that represent the state / data of an application. Therefore, an application or data model.
What do we mean:
- view model types
- action method parameter types
So, your application model remains the same. Both GetModel and PostModel are just two classes / types in this model. They are not a model in their own way.
Various types? Of course we can!
In your case, you use the GetModel view model type, and then pass your data to the PostModel action parameter. Since these two classes / types have properties with the same matching names, the PostModel will be able to populate the PostModel properties by PostModel . If the property names are not the same, you will need to change the view to rename the inputs to display the property names of the POST action type.
You can also have a view with type GetModel , and then send an action with several different types of diagrams, for example:
public ActionResult Edit(Person person, IList<Address> addresses) { ... }
Or something else. You just need to make sure that these messages can be associated with these parameters and their properties like ...
Robert Koritnik
source share