I am a bit confused how the three components - Model, View, Controller - interact with each other in MVC architecture. Sometimes I feel I know how MVC works and sometimes I feel I don't know its inner working properly.
What I know about MVC architecture is -
Here in my opinion, View never talks to the Model directly. The interaction between the View and Model will be handled by the Controller only .
So far so good!
But when I see diagrams like below then I get confused. In the below diagram, the left arrow shows that View component can also interact with the Model component.
Also in this code-project article, it is written that "A model is accessible by both controller and view" and "a view can use model to display data".
So kindly clarify whether a model is accessible only by the controller or by both the controller and the view. And if second one is also correct then in what situation this is possible. I work on ASP.NET MVC Framework and here any interaction is done through a controller object. I have never encountered a situation where a view directly talks to the model object.
There's MVC, the pattern, and MVC, the web application framework developed by Microsoft and confusingly named after the pattern, so it's best to break those two out and discuss separately.
In MVC, the pattern, you'll find the following:
In MVC, the web application framework:
Despite the name, the MVC framework only loosely implements the MVC pattern. However, in both, the Model is accessible by both the controller and the view, so your fundamental understanding there is flawed. In the case of the MVC framework, though, you could say that only the view model is accessible to the view. Since the "Model" in the MVC framework is not just one thing, there are constituent parts that should not be accessible by the view, namely: the DAL layer and potentially the entity, unless the entity is doing double duty as the view model, as well.
In Case If the view is Strongly typed with any models then we can say
View=> models
In Case if view is not strongly typed with models then we can say
controller=>Models=> Views
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.