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.
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.
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.
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:
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.
Thanks for the information. TempData is wonderful.
is working on a reply...