我想设计一个游戏创建控制器/视图过程,其中
用户将获得STEP 1:CREATE GAME然后点击提交以转到步骤2:选择一个位置然后转到步骤3邀请朋友并确认网站的创建。
如何使用ASP.NET MVC 4(我目前正在使用EF5并正确生成所有模型等等)。
非常感谢您的反馈
答案 0 :(得分:2)
最简单的方法是使用Session和GET / POST请求。看到这个过于简单的例子:
class SignupController : Controller
{
public ViewResult CreateGame()
{
// render the view
}
[HttpPost]
public ViewResult CreateGame(Game model)
{
if (ModelState.IsValid)
{
// store "model" in session
return RedirectToAction("location");
}
else
{
return View("edit", model);
}
}
public ViewResult Location()
{
// render the view
}
[HttpPost]
public ViewResult Location(int id, Location location)
{
if (ModelState.IsValid)
{
RedirectToAction("...")
}
else
{
return View("edit", location);
}
}
}