I have two methods in the SurveyController:
public ActionResult Index(string surveyId, string surveyWaveId, string programId)
and
public ActionResult Index(string hash)
I would like to be able to go to:
Survey/Index/{string} or Survey/Index/{string}/{string}/{string}
and route to the correct action based on the number of parameters supplied. Is this possible with MVC5? I also have this in my RouteConfig.
routes.MapRoute(
name: "SurveyEmailLink",
url: "Survey/Index/{hash}",
defaults: new { controller = "Survey", action = "Index"},
namespaces: new[] { "Cobalt.Controllers" }
);
routes.MapRoute(
name: "SurveyIconLink",
url: "Survey/Index/{surveyId}/{surveyWaveId}/{programId}",
defaults: new { controller = "Survey", action = "Index" },
namespaces: new[] { "Cobalt.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "Cobalt.Controllers" }
);
Thanks in advance!