asp.net mvc 3 - Mvc maproute multiple page levels -


is there anyway can reduce amount of duplication maproute registration in global.ascx file mulit page levels below.

    routes.maproute("article-level1",                 "{sluglevel1}/article/{id}/{article-title}",                 new { controller = "article", action = "detail", id = urlparameter.optional });   routes.maproute("article-level2",                 "{sluglevel1}/{sluglevel2}/article/{id}/{article-title}",                 new { controller = "article", action = "detail", id = urlparameter.optional });  routes.maproute("article-level3",                 "{sluglevel1}/{sluglevel2}/{sluglevel3}/article/{id}/{article-title}",                 new { controller = "article", action = "detail", id = urlparameter.optional });  ... more levels 4 10 ... 

please let me know if there better way do.

you can explore "catch-all" route parameters: handling variable number of segments in url pattern.

but need change structure of routes this:

"article/{id}/{article-title}/{*sluglevels}"


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -