// GET: Kit/Random public ActionResult Random() { var kit = new Kit() { Name = "First Kit" }; //var viewResult = new ViewResult(); //the viewdata is not a regular dictionary, you use it as key value pairs or as model object var members = new List <Member> { new Member { Name = "Member 1" }, new Member { Name = "Member 2" } }; var viewModel = new RandomKitViewModel { Kit = kit, Members = members }; return(View(viewModel)); //the below are older ways that are not good choices - you have to update the @view if you use the below //ViewData["Kit"] = kit; //ViewBag.RandomKit = kit; //return View(); //other return options below: //return Content("Hello World!"); //return HttpNotFound(); //return new EmptyResult(); //return RedirectToAction("Index", "Home", new {page = 1, sortBy = "name"} ); //(naming the action and controller, and third is the optional arguments to appear as part of the query string) }
// GET: Kits/Random public ActionResult Random() { var kit = new Kit() { Name = "Cake" }; var members = new List <Member> { new Member { Name = "Member 1" }, new Member { Name = "Member 2" } }; var viewModel = new RandomKitViewModel { Kit = kit, Members = members }; return(View(viewModel)); }