Can we use the same view across multiple controllers? Explain in detail.

Solution

Yes, we can use the same view across multiple controllers.

As we know MVC provides a clear separation of concern. Each component (Model, Controller and view) have its own responsibilities and works independently.

Controller is responsible for handling and processing the user requests.

Model is responsible for holding data and representing the type of data.

Views are used to display the user interface on the browser.

So we can return any view in response on user request from any controller irrespective of where views are situated only we need to specify correct path of view so that MVC framework can locate that.

Also, we can pass the same model in different views.

 

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media