Asp.net mvc dynamic / relative routing

I am developing a website that has a modular structure. Each URL segment represents a content item. For example, URL: www.mysite.com/blogs/programming/2010/01/

The root element is 'blogs' of type 'area'. He has children's "programming" like "blog".

Now there is "2010/01" to the left of the URL. The last valid (routable) programming element was a blog, so I need to map "2010/01" to action

BlogController.Date (int blogid, int year, int? Month, int? Day)

Each controller comes with a module (separate dll) that registers some types of elements (blog-type registers like β€œblog” (routable) and β€œpost” (non-routable). β€œBlog” can have children of type β€œpost”) When the last one is detected valid (routable) element of the URL, the logic knows which assembly and controller to look for. Now I need a way to invoke the correct action with the correct parameters.

Some routes for a blog item

{year} /
{year} / {month}
{year} / {month} / {day}
feed /
category / {category-name} /
tag / {tag-name} /
search / {* phrase}
{* post-name}

Any suggestions what would be an easy way for routing?

+3
source share
1

, "BlogModel" . , . , ModelBinder "BlogModelBinder" ModelBinderFactory ( MVC3 DependencyResolver). "BlogModelBinder" RouteData "BlogModel".

, , : URL- . - URL- , , , .

+1

Source: https://habr.com/ru/post/1729223/


All Articles