Why isn’t this working. It keeps telling me edit needs a EditStudyModel when I redirect in my Create method. A Redirect should do a get, right?
public ViewResult Create()
{
var createStudyModel = new CreateStudyModel();
return View(createStudyModel);
}
[HttpPost]
public ActionResult Create(CreateStudyModel createStudyModel)
{
try
{
//TODO: Send CreateStudyCommand
return RedirectToAction("Edit", new { scientificStudyId = new Guid("{1C965285-788A-4B67-9894-3D0D46949F11}") });
}
catch
{
return View(createStudyModel);
}
}
[GET("ScientificStudy/Create/{scientificStudyId}")]
public ActionResult Edit(Guid scientificStudyId)
{
//TODO: Query real model
var model = new EditStudyModel() {StudyNr = "T01", StudyName = "Test"};
return View(model);
}
[HttpPost]
public ActionResult Edit(EditStudyModel editStudyModel)
{
try
{
//TODO: Send UpdateStudyCommand
return RedirectToAction(""); //TODO: Terug naar Studie lijst
}
catch
{
return View(editStudyModel);
}
}
I found the issue. I copy paste my create.cshtml to edit.cshtml Forgot to change the first line:
@model Website.Models.CreateStudyModel–> to –>@model Website.Models.EditStudyModel