ThomasWeiss
ThomasWeiss

Reputation: 1302

Transforming action name in route declaration

I'm wondering if there is a way to declare routes in MVC3 so that the route "zone1/{controller}/{action}" would direct to {controller}.zone1{action} method and "zone2/{controller}/{action}" would direct to {controller}.zone2{action} method, for example. So that's basically transforming the target action name based on the route.

Thanks

Upvotes: 0

Views: 118

Answers (1)

Adam Tuliper
Adam Tuliper

Reputation: 30152

Check out The Attribute Routing project. You can specify on your methods the routes which I feel is a bit easier to read. Here's a decent blurb on it: http://gregorsuttie.com/2012/01/12/attributerouting-for-mvc/

You could also write your own custom route handler but I don't believe you can do what you want without some custom code. I could be wrong here though. The attribute routing project should work just fine for what you want however.

Upvotes: 1

Related Questions