ASP.NET MVC 3 Routing confuses me. I feel like I've read everything I can, but sometimes, I still just don't get it. I am trying to create a URL that I can visit that looks like
/authorized/home/children/{childID}
I want that URL to show an HTML view that loads the contents for a specific child. My view is defined as follows:
/Views/Authorized/Home/Children/Child.cshtml
In my global.asax.cs file, I have added the following route:
routes.MapRoute(
"Child", // Route name
"{controller}/Home/Children/{action}/{id}",
new { controller = "Authorized", action = "Child", id = UrlParameter.Optional }
);
In AuthorizedController.cs, I have the following:
public ActionResult Child(string id)
{
return View("~/Views/Authorized/Home/Children/Child.cshtml");
}
If I visit /authorized/home/children, I see the contents of Child.cshtml. However, if I visit /authorized/home/children/1, I get a 404.
What am I doing wrong? Thank you