For my administration area I have created a special route. I did this so my urls look cleaner, and it avoids the problem of me having 2 controllers with the same name.
Example: I have a UserController and another AdminUserController for the admin site of the application.
I don't want URL's like:
http://www.example.com/user/...
http://www.example.com/admin/adminuser/...
I want the admin url's to look like:
http://www.example.com/admin/user/...
Now to get this url structure, I tried this:
I named my admin controller: AdminUserController
Then my route looks like:
routes.Add(new Route("admin/Admin{controller}/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Admin", action = "index", Id=""});
});
Can this work? (the route is currently not working)
I made sure to have this route above the generic route.
Update
I want all my admin urls to be prefixed with the /admin/ folder, so:
www.example.com/admin/user
www.example.com/admin/settings
www.example.com/admin/articles
and non-admin are like:
www.example.com/user
www.example.com/articles