views:

25

answers:

1

I want my urls structure to be like this:

www.stackoverflow.com/order/...

www.stackoverflow.com/admin/order/...

Now both of the above are using different controllers.

/controllers/ordercontroller
/controllers/admin/ordercontroller

Is there a way that I can have this url structure?

I was thinking if I could do this:

/controllers/ordercontroller
/controllers/admin/adminordercontroller

And somehow, in my routes, prefix the name of all the admin related controllers with 'admin' ?

+2  A: 

Sure, no problem. Remember you can have static text in routes as well.

routes.MapRoute("admin", "admin/{controller}/{action}/{id}", ....

routes.MapRoute("normal", "{controller}/{action}/{id}", ...

The key thing here is to make sure that the admin route is first, so that it has first crack at matching the URL. Otherwise the "normal" route will swallow it, because it also matches.

womp
but what about the naming of the admin related urls, I want them just like /admin/order/ and have /order/ at the same time. how can I do that?
Blankman