I have a view where I'm using a specific layout.cshtml file, other than the main shared layout page: "_LayoutExCr"
This is fine for the Get part of the controller:
//
// GET: /Exhibitor/Create
public ActionResult Create()
{
return View("Create","_LayoutExCr");
}
This works fine - and displays the Create view with the specific _LayoutExCr "master" page.
However, in my POST for the Create method, if the wrong access code is entered, I want to return to the same view, using the _LayoutExCr "master" page - but VS2012 Express underlines in Red:
return View(exhibitor, "_LayoutExCr");
The best overloaded method match for 'System.Web.Mvc.Controller.View(string, string)' has some invalid arguments
//
// POST: /Exhibitor/Create
[HttpPost]
public ActionResult Create(Exhibitor exhibitor)
{
if (ModelState.IsValid)
{
if (exhibitor.AccessCode == "myaccesscode")
{
db.Exhibitors.Add(exhibitor);
db.SaveChanges();
return RedirectToAction("Thankyou");
}
else
{
ModelState.AddModelError("", "The Access Code provided is incorrect.");
return View(exhibitor, "_LayoutExCr");
}
}
return View(exhibitor, "_LayoutExCr");
}
Can anyone let me know how to return the model to the view, using that same layout page please?
Thank you,
Mark