Copied to clipboard

Flag this post as spam?

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


  • Roger Ingbretson 4 posts 84 karma points
    Jan 07, 2017 @ 22:46
    Roger Ingbretson
    0

    Pass information from surface controller to web page

    Hi. I'm fairly new to Umbraco. I'm developing a website where a person enters information on one web page and the corresponding surface controller uses that data to extract information from an external source. The surface controller then redirects to another web page based upon the contents of the extracted data. Can anyone give me examples on how to access the data extracted in the surface controller on the new/redirected web page. The data consists of array fields so I would prefer not to pass the information as part of the URL. Thanks in advance for your help.

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jan 08, 2017 @ 17:28
    Nik
    100

    Hi Roger,

    The scenario you are describing sounds like it could be resolved using TempData. If you aren't aware there are 3 types of "temporary" data objects in MVC.

    Tempdata, ViewBag and ViewData.

    This blog here can give you a decent explination of them all but effectively in your surface controller you can do the following:

    TempData["MyDataToPassArround"] = myDataArray
    

    Then in your view you can access it using the same key. TempData is great because it persists beyond a single request so redirects continue with the data so works well with Umbracos Routing engine.

  • Roger Ingbretson 4 posts 84 karma points
    Jan 16, 2017 @ 15:08
    Roger Ingbretson
    0

    Thanks for the information. TempData is wonderful.

Please Sign in or register to post replies

Write your reply to:

Draft