Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damion 96 posts 331 karma points
    Mar 29, 2019 @ 14:55
    Damion
    0

    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?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 29, 2019 @ 15:11
    Alex Skrypnyk
    1

    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?

  • Damion 96 posts 331 karma points
    Mar 29, 2019 @ 15:15
    Damion
    0

    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

  • Kimbrough 11 posts 141 karma points
    Mar 29, 2019 @ 15:45
    Kimbrough
    100

    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.

Please Sign in or register to post replies

Write your reply to:

Draft