RedirectToAction(..) with complex deep object fails

前端 未结 4 1825
生来不讨喜
生来不讨喜 2021-01-04 13:18

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
{
         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 14:11

    I agree with @Dennis -- unless you want the Url to change, then you'll have to think of something else. The reason is that RedirectToAction doesn't serialize the data, it simply iterates over the properties in the route values object constructing a query string with the keys being the property names and the values the string representation of the property values. If you want to have the Url change, then using TempData is probably the easiest way to do this, although you could also store the item in the database, pass the id to the Result method, and reconstitute it from there.

提交回复
热议问题