ASP.NET MVC routing - part of controller name in url

178 Views Asked by At

I need a routing that maps

admin/{PartOfControllerName}/{action}

to the controller:

Admin{PartOfControllerName}Controller

For example map admin/post/new to AdminPostController and its New action.

Thanks.

1

There are 1 best solutions below

0
Rocky Zairil On

one way to do it is to decorate action with Route metadata

[Route("admin/post/new")]
public ActionResult New(...)