I have a controller action as the below
public class HomeController : BaseController
{
public JsonResult Index(ComplexObject customObject)
{
...
}
...
}
This is what ComplexObject looks like
public class ComplexObject
{
public int? Id { get; set; }
...
}
Here is what I have defined in my area registration:
context.MapRoute(
"MyArea_default",
"MyArea/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "MyApp.Areas.MyArea.Controllers" }
);
What I am trying to do is access my controller action like
https://mysite.com/MyArea/{value_of_id}
and have my modelbinder for ComplexObject initialize a new ComplexObject with the id that was passed in.
Is this possible? An internet search offered no help at all.
Many thanks in advance for your help!
Yes, mvc will bind a route parameter to a complex obejct. Have you actually tried it?