This might be a result from the WebForms-centric way of thinking and a dirty habit, but I need to have the following flow on the web site:
- User clicks a button (or submits some data in another way)
- This posts the form to the Home controller.
- Home controller transfers the data to another controller's action
I tried using the default route's 'id' parameter but this puts a long XML into the address field in the browser and, besides, just doesn't work.
The right option for this scenario is using TempData. This translates to simply using
TempData.Add("customMessage", xmlContent);return RedirectToAction("Index", "CustomMessage");
in the Home controller, and
var xmlContent = (string) TempData["customMessage"];
in the receiving controller. (Passing the same data to the view is another matter. Using ViewBag is the 'quick & dirty' way. See related post.)