I am using the same model between 2 views, but when posting the model to the second view it puts all the previously entered data in the URL. Is it possible to send the populated model to the second view without posting the data in the URL?
Controller code:
[HttpPost]
public ActionResult ViewExample1(.Models.RegisterModel model)
{
if (ModelState.IsValid)
{
return RedirectToAction("ViewExample2", model);
}
return View(model);
}
public ActionResult ViewExample2(Models.RegisterModel model)
{
return View(model);
}
Second view code where I use HiddenFor to persist the data when this view is posted back:
<% using (Html.BeginForm(null, null, FormMethod.Post, new { id="ViewExample2"})) { %>
<%: Html.HiddenFor(model => model.UserName)%>
<% } %>