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 -
- User requests are intercepted by Controller whether it is a URL
request or any event raised by the user on the page. - Then controller processes the user input and talks to the Model.
- Model prepares data and sends back to the Controller.
- Finally, controller hands over data back to the view and is displayed to the user.
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.
Aucun commentaire:
Enregistrer un commentaire