I’m so obsessed with semantics and I’d like to create meaningful sentences through ASP.NET MVC’s route rules which semantically describe the action. For example, I want to assign an article to some categories, and to do that, I’d like to have these URLs:
/assign/article-name/to-categories
which should have this rule:
assign/{articleName}/to-categories
and
/assign/article-name/to/category-title/category
which should have this rule:
assign/{articleName}/to/{categoryTitle}/category.
Some examples of desired URLs are:
assign/seo/to/computer/category, or assign/how-to-drive-fast/to/general-knowledge/category, or URLs like that.
The problem is that, I’m not professional at MVC routing and I can’t make this work. Any help please!
The following route definition should work:
where you would have an
ArticlesController:Now for example the following request
assign/seo/to/computer/categorywill be routed to theAssignaction which will be passedarticleName = seoandcategoryTitle = computer.