I have a problem with an MVC action I'm trying to write. I want a model to be supplied as an optional parameter to the action so that the model can be fetched from TempData instead if there is no model supplied. So I have the following:
public ActionResult Page1(TestFormViewModel model = null)
{
if (model == null)
{
model = TempData["model"] as TestFormViewModel;
}
return View("Page1", model);
}
But every time I try this, the model is a newly instantiated copy of the TestFormViewModel class, instead of being null. How can I make the parameter null when there is no model supplied?