Created
February 19, 2018 16:35
-
-
Save KeesCBakker/c034ff3e163333cb6ba21fd3473aca05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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