Rahul
Rahul

Reputation: 2307

Umbraco + mvc page redirect with data

I want to redirect to other Umbraco page with model data.

Currently i am just redirecting to other Umbraco page but not with model data.

 public ActionResult CNOReplacement(MasterViewModel Model)
        {
            ViewBag.TestData = "Testing ViewBag data passing !!";
            return RedirectToUmbracoPage(1098);   
        }

Even i have tried by passing viewmodel but that is also not working.

Upvotes: 1

Views: 1899

Answers (2)

Rahul
Rahul

Reputation: 2307

I did not get any solution but have done this using an alternate way,

I have used HttpContext Session Variable to Get Data on Each Umbraco Page.

In controller Action I have created one session

Session["MasterViewModel"]=new MasterViewModel();

And when redirecting to other Umbraco page using below code:

public ActionResult CNOReplacement(MasterViewModel Model)
        {
            return RedirectToUmbracoPage(1098);   
        }

And in View we are getting Session Variable as::

@inherits Proj.ViewModel.MasterViewModel
@{var PerviousPageModel= Session["MasterViewModel"] as MasterViewModel}

Upvotes: 1

Narek Arzumanyan
Narek Arzumanyan

Reputation: 616

[HttpGet]
public ActionResult AAA()
{
GameModel model = new GameModel() { Id = 10 };
return RedirectToAction("BBB", "Game", model);
}

public ActionResult BBB(GameModel model)
{
return View();
}
enter image description here>

Upvotes: 0

Related Questions