I've racked my brain on this for a day and a half and I'm stumped.
I have an Mvc3 site and I'm implementing a wizard (multi-step form).
The first page receives a view model from the controller and this is serialised to Javascript.
All goes well to the post method below:
$('#nextButton').click(function (evt) {
// Validate the form, if validation passes, submit the form.
evt.preventDefault();
var $form = $('form');
if ($form.valid()) {
var viewModel = JSON.stringify(model);
$.post(
"SampleSubmission/Home/Index",
{ 'viewModel': viewModel }
);
}
});
Then it hits the controller action below:
[HttpPost]
public ActionResult Index(string viewModel)
{
_viewModel = JsonConvert.DeserializeObject<SampleSubmissionViewModel>(viewModel);
// Save Model to Session.
Session[SessionViewModel] = _viewModel;
// If platform Id != null, workflow has already begun.
if (ModelState.IsValid)
{
return RedirectToAction("SystemDetail");
}
return View(_viewModel);
}
[HttpGet]
public ActionResult SystemDetail()
{
// Page 2- System Details.
return View(_viewModel);
}
The redirection works but no second page is shown.
If I look in Fiddler, the page is returned as it should be.
I'm storing the model in Session because it's an intranet site, before anybody says :-)
Any ideas on how to show the second page?
Cheers,
Jules