Skip to content

Instantly share code, notes, and snippets.

@KeesCBakker
Created February 19, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeesCBakker/c034ff3e163333cb6ba21fd3473aca05 to your computer and use it in GitHub Desktop.
Save KeesCBakker/c034ff3e163333cb6ba21fd3473aca05 to your computer and use it in GitHub Desktop.
app.UseMvc(routes =>
{
var shopRoutingConstraint = new RegexNamedGroupRoutingConstraint(
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})_(?<SegmentCode>[A-Z0-9]{3})_(?<ProductId>\d+)/?$",
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})_(?<SegmentCode>[A-Z0-9]{3})/?$",
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})/?$",
"/(?<CategoryCode>[A-Z0-9]{3})/?$"
);
routes.MapRoute
(
name: "nav-by-codes",
template: "{*url}",
constraints: new { url = shopRoutingConstraint },
defaults: new { controller = "Shop", action = "Detail" }
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment