Pass complex objects to MVC Get parameters
Posted
by VJ
on Stack Overflow
See other posts from Stack Overflow
or by VJ
Published on 2010-05-13T15:00:48Z
Indexed on
2010/05/13
15:04 UTC
Read the original article
Hit count: 237
asp.net-mvc
|parameter-passing
I am wanting to pass something like the following to my view from my controller via GET not POST:
public class MyDTO
{
public string val1 { get; set; }
public string val2 { get; set; }
public MyObject obj { get; set; }
}
public class MyObject
{
public int SomeInt { get; set; }
public string ACoolValue { get; set; }
public string YetAnotherCoolValue { get; set; }
}
And then the controller would like like this. (Note it is a GET):
public ActionResult MyView(MyDTO dto)
{
return View(dto)
}
The problem is that the instance of MyObject is coming back as null, where val1 and val2 have data. Has anyone run across this?
© Stack Overflow or respective owner