Copied to clipboard

Flag this post as spam?

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


  • David Peck 690 posts 1896 karma points c-trib
    Jan 05, 2017 @ 10:26
    David Peck
    0

    Passing complex data to an MVC Action (opinions please)

    I use Nested Content a lot. An example might be a sidebar when users add several different types of content (I'm don't really want in to discussing Nested Content/ Archetype/ Grid Layout). However on occasion one of these sidebar elements is complex and warrants rendering via it's own MVC Action.

    The problem I have is that in these situations I have content from the sidebar element that I want the Action to have, but there may be many fields in the NestedContent IPublishedContent object and I need to pass these to the action.

    So what is the best thing to do?:

    1. Pass the many fields as individual route values
    2. Pass the IPublishedContent as a route value (passing such a complex object seems wrong)
    3. Create a new classes just for passing my data as a single route value (this would be complex because there is nested content inside nested content)
    4. Pass the page id and the index of the sidebar element and re-retrieve the data from the content cache
    5. Use TempData or other session based object
    6. Use the RequestCache
    7. Any other ideas?

    Cheers,

    David

Please Sign in or register to post replies

Write your reply to:

Draft