MVC 3 - parsing a FormCollection for a model

For my sample application that I am creating, I am currently forced to pass a FormCollection object into my action method when trying to make ajax updates in my view.

The reason I decided to pass FormCollection is because my view is quite complex and contains nested collections. If I were in Serialize and Json.Stringify, it wraps these nested collections when passed to my action method.

Is there a good technique to map my FormCollection object to an instance of my ViewModel once inside the controller?

thanks

+4
source share
1 answer

You can use TryUpdateModel<TypeOfYourModel>(YourModelInstance)

+2
source

Source: https://habr.com/ru/post/1344561/


All Articles