I've used below snippet to redirect user to different action/views based on selected contract type:
public ActionResult Create(ContractViewModelCreate contract)
{
if (ModelState.IsValid)
{
if (contract.ContractType == Contract.ContractTypeENUM.SectionBased)
retu RedirectToAction("Create", "SectionBasedContract", new { area = "Admin" });
else if (contract.ContractType == Contract.ContractTypeENUM.UnitBased)
retu RedirectToAction("Create", "UnitBasedContract", new { area = "Admin" });
else
retu new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Utils.AddErrorsString(ModelState, "Select project type");
retu View(contract);
}
However the first RedirectToAction leads to reading of layout file by ruing _ViewStart.cs in Admin area and 2nd one leads to ruing to _ViewStart.cs in root application area and don't care about Route Objects (to run in Admin Area). Since this action is ruing inside Admin area ruing of retu RedirectToAction("Create", "UnitBasedContract", new { area = "Admin" }); lead to layout change.
I caot find the reason, does anyone knows the reason?
