I'm trying to figure out how to pass a model across views
Here is what I'm doing, I have a Register, RegisterConfirm, RegisterComplete views.
User starts at Register, fills info, clicks continue and posts to RegisterConfirm where they click checkbox to agree to privacy policy then post to RegisterComplete which creates the user based on the model in the first Register view.
Code:
[GET("Account/Register")] public ActionResult Register() { return View(); } [POST("Account/Register/Confirm")] public ActionResult RegisterConfirm(RegisterModel model) { if (ModelState.IsValid) { return View(model); } else { return View("Register", model); } } [POST("Account/Register/Complete")] public ActionResult RegisterComplete(RegisterModel model, bool agree) { if (agree) { // Create User } return View("Register", model); }
View Form
Register: @using (Html.BeginForm("RegisterConfirm", "Account", FormMethod.Post, new { @id = "create" })) { Register Confirm: @using (Html.BeginForm("RegisterComplete", "Account", FormMethod.Post, new { @id = "create" })) {
Problem is, when I'm getting to RegisterComplete, model values are empty... any ideas or is this not possible? Or should this work and I need to double check my registercomplete?