我正在从一个控制器重定向到另一个控制器,并在路由值中发送一个对象,但该对象返回为空:
class Person {
string Name {get; set;}
}
FirstController {
ActionResult something() {
Person p = new Person() { Name = "name" };
return redirectToAction("AddPerson", "Second", new { person = p });
}
}
SecondController {
ActionResult AddPerson(Person person) {
//I'm hitting this action method but the "person" object is always null for some reason
//add person
}
}
是因为不允许传递物体吗?
我尝试将参数更改为字符串而不是Person
对象,然后只发送它,person.Name
然后它发送它...但是为什么呢?