I'm working on a MVC application where an user can select a specific project based on a DropDownList. I prefer to have this DropDownList on the layout page, and I would like to use it's value in the routing as each Controller will need this value to select the correct data.
I started out with a PartialView but I believe this is not the way I should go down, I think it's better to use Html.Action on a Generic controller to return the Html for this dropdown.
Now i'm confused though on how to use the value in each URL to feed the controllers with the correct project for data selection.
I have two routes configured, the default is still when the user has not selected a project to work on. How would I use the selected value of the DropDownList in each URL? Or should I follow another route?
routes.MapRoute(
name: "Project",
url: "project/{project}/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);