<p>I'm thinking of learning the <code>ASP.NET MVC</code> framework for an upcoming project.  Can I use the advanced routing to create long URLs based on the sitemap hierarchy?</p>

<p>Example navigation path:</p>

<p><strong>Home > Shop > Products > Household > Kitchen > Cookware > Cooksets > Nonstick</strong></p>

<p>Typical (I think) MVC URL:<br/>
<a href="http://example.com/products/category/NonstickCooksets" rel="nofollow noreferrer">http://example.com/products/category/NonstickCooksets</a></p>

<p>Desired URL:<br/>
<a href="http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick" rel="nofollow noreferrer">http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick</a></p>

<p>Can I do this?</p>

[{'answer_id': 14991, 'author': 'J Wynia', 'author_id': 1124, 'author_profile': 'https://Stackoverflow.com/users/1124', 'pm_score': 2, 'selected': False, 'text': '<p>The MVC routing lets you define pretty much any structure you want, you just need to define what each of the pieces mean semantically. You can have bits that are "hard-coded", like "shop/products", and then define the rest as variable, "{category}/{subcategory}/{speciality}", etc.</p>\n\n<p>You can also define several routes that all map to the same end point if you like. Basically, when a URL comes into your MVC app, it goes through the routing table until it finds a pattern that matches, fills in the variables and passes the request off to the appropriate controller for processing.</p>\n\n<p>While the default route is a simple Controller, Action, Id kind of setup, that\'s certainly not the extent of what you can do.</p>\n'}, {'answer_id': 36833, 'author': 'Andrei Rînea', 'author_id': 1796, 'author_profile': 'https://Stackoverflow.com/users/1796', 'pm_score': 4, 'selected': True, 'text': '<p>Zack, if I understand right you want unlimited depth of the subcategories. No biggie, since MVC Preview 3 (I think 3 or 4) this has been solved.</p>\n\n<p>Just define a route like</p>\n\n<p>"{controller}/{action}/{*categoryPath}"</p>\n\n<p>for an url such as :</p>\n\n<p><a href="http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick" rel="noreferrer">http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick</a></p>\n\n<p>you should have a ShopController with a Products action :</p>\n\n<pre><code>public class ShopController : Controller\n{\n...\n    public ActionResult Products(string categoryPath)\n    {\n        // the categoryPath value would be\n        // "household/kitchen/cookware/cooksets/nonstick". Process it (for ex. split it)\n        // and then decide what you do..\n        return View();\n    }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/14923', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/83/']