Normally my URLs look like the standard: www.example.com/controller/action
Now I want to setup my administration section like:
www.example.com/admin/ www.example.com/admin/user/list www.example.com/admin/content/add etc.
So the format is: www.example.com/admin/controller/action
I can’t seem to figure out how to setup the routes so it looks like the above.
You just need to map a new path with the ‘admin’ section hardcoded at the beginning of the route definition.
For example add this to your routes in
RegisterRoutesin theGlobal.asax.csfile and make sure it appears above the default route (assuming you haven’t added other routes):Note: the ‘admin’ part hardcoded at the start of the route definition.
Note 2: If you have added other routes beyond the default you will need to make sure your routes are ordered correctly.
Here is a link to a good blog post from Scott Guthrie regarding MVC routing: URL Routing