I have a home page whose controller has an action result which returns a partial view.
That partial contains a RenderAction which calls code in another controller to build a model based on IPublishedContent, then return another partial with the model passed in.
Although it all seems to work, is it 'acceptable' in MVC?
I'm just not sure about calling another controller from a partial, which was it's self called from a controller.
I would have liked to keep the controllers for overriding the routes, but if it works then fair enough, I was just interested to see what others thought.
Yes, it is acceptable. In addition to providing a "separation of concerns" another benefit to MVC is that it enables us to compartmentalize functionality so views are reusable throughout the site. It would be difficult to leverage that flexibility if you aren't willing to call a partial view from within another partial or in some cases even pass control from one controller to another.
Does this approach 'break' MVC?
I have a home page whose controller has an action result which returns a partial view.
That partial contains a RenderAction which calls code in another controller to build a model based on IPublishedContent, then return another partial with the model passed in.
Although it all seems to work, is it 'acceptable' in MVC?
Everything you described is Model View and Controllers - so it's not broken MVC.
I would say that it's fine.
Why you don't like this approach?
Hi,
I'm just not sure about calling another controller from a partial, which was it's self called from a controller.
I would have liked to keep the controllers for overriding the routes, but if it works then fair enough, I was just interested to see what others thought.
thanks
Yes, it is acceptable. In addition to providing a "separation of concerns" another benefit to MVC is that it enables us to compartmentalize functionality so views are reusable throughout the site. It would be difficult to leverage that flexibility if you aren't willing to call a partial view from within another partial or in some cases even pass control from one controller to another.
is working on a reply...