Is there a way to pass the complete model from the view back to the controller (without using JSON please)?
My model is a list e.g.
List<ExmapleClass>
I want to be able to pass it back to the controller, sort, then pass it back to the view to be displayed, so that I don’t have to go back to the database to get the original data.
I guess having the list as a (class) member variable in the constructor will eliminate the need to pass the model back and forth, but do I have other options?
Conceptually within the servicing of a single request the communication from the controller to the view is one way. The controller decides on the view to be rendered, passes it a model, and execution never passes back to the controller.
You could execute a child action from within a view, which may achieve something similar to what you’re after, but it’s not clear based on your question.
If you’re talking about communication that takes place across interaction with the user then you may be able to achieve something like this using TempData, where the view stores information in TempData to be consumed by the next controller that executes.
If your concern is performance based on having to repeatedly query a data source I would strongly advise you think about how to cache this data in a service or data access layer rather then try to use the view / controller interaction as a way of caching.