I need to build a controller action to handle this pattern:
example.com/aString
where aString can be any of a set of arbitrary strings. The controller would cycle thru each of the possible values and, if none match, redirect to a 404.
I'd think it's just a matter of recoding the catch-all but am so far coming up blank. Currently using Sherviniv's suggestion:
//Catchall affiliate shortcuts.
routes.MapRoute(
name: "affLanding",
url: "{query}",
defaults: new
{
controller = "Home",
action = "MatchString"
}
);
Controller:
public ActionResult MatchString(string query)
{
_logger.Info("affLanding: " + query);
return View();
}
If i hard-code my 'search' string into the route.config things work:
routes.MapRoute(
name: "search",
url: "aString",
defaults: new { controller = "home", action = "MatchString"}
);