This is how i designed the RegisterRoutes function. and based on the condition am selecting the Action for HomeController. So far so Good.
string env = "Index";
if (some condition from config)
{
env = "Test";
}
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = env, id = "" }
);
Problem starts here when am reirecting to other controller by default if dont specify an action(for eg: am calling SampleController) the "env"(Which was set in RegisterRoutes is called. if env is set as "Index" Index action is called, if env is set "Test" Test action is called in all other controllers as well.
My intention is only for HomeController this condition should be set and for all other controller i want Index to be the default action.
How do i make this work ? is it possible to dynamically change the action for all other controllers ? Is there a better way i can do this.
Share your suggestions
Thanks
"Home/{action}/{id}", new { controller = "Home", action = env }and the default route"{controller}/{action}/{id}", new { controller = "Home", action = "Index" }"Home/{action}/{id}"first? (the order is important)