This simpliest implementation should work, route registration:
routes.MapRoute(
name: "Templates",
url: "{pageAlias}",
defaults: new { controller = "BasePageTemplate", action = "Index" }
constraints: new { DynamicTemplate = new DynamicTemplateConstraint() }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
And the constraint:
public class SiteCultureConstraint : IRouteConstraint
{
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
return !String.Equals(route.Url, "sample", StringComparison.OrdinalIgnoreCase);
}
}
However, I wouldn't say this is a good approach as this looks to be too specific about route names. Please consider using some of the dynamic routing implementations instead, like this one by Trevor Fayas.