Hi,
I'm trying to pass an object from one controller action to another. The object that I'm passing around looks more or less like this:
public class Person
{
public string Name { get; set; }
public List<PhoneNumber> PhoneNumbers {get; set; }
public List<Address> Addresses { get; set; }
}
My Controller looks like this:
public class DialogController : Controller
{
public ActionResult Index()
{
// Complex object structure created
Person person = new Person();
person.PhoneNumbers = new List();
person.PhoneNumbers.Add("12341324");
return RedirectToAction("Result", "Dialog", person);
}
public ActionResult Result(Person person)
{
string number = person.PhoneNumbers[0].ToString();
return View();
}
}
The result method fails with a null pointer exception since the PhoneNumbers list is suddenly null after invoking the Result action with the RedirectToAction() method.
Has anyone seen this type of behavior before?
Cheers,
Peter