i’ve created a basic mvc3 website whereby each controller represents the first folder in a url structure.
for example, the “food” and “drinks” folders below are controller. there are only two controllers which contain all of the sub-items in them.
ie in the first line of the example, controller=food, method=asian
in the second line controller=food, method=pad-thai and so on and so forth.
http://www.mysite.com/food/asian/
http://www.mysite.com/food/asian/pad-thai
http://www.mysite.com/food/italian/chicken-parmigiana
http://www.mysite.com/drinks/cocktails/bloody-mary
how would i write routes so that http://www.mysite.com/food/asian/pad-thai will direct to the food controller and the paid thai method within that controller, and also have a rule to send from http://www.mysite.com/food/asian/ to the food controller and asian index method??
The MVC design pattern isn’t for rewriting URLs to point to folder structures. It can do this but it certainly isn’t its main purpose. If you’re trying to create a URL structure with static content, it might be easier to use the URL rewriting functionality built into IIS.
If you’re creating a full MVC application, set up
FoodControllerandDrinkControllerto serve up your views, for example:Using the example above, your route might look a little like this:
Your question doesn’t contain much detail about your implementation, so if you’d like me to expand on anything, please update your question.