Let say I have Event controller. In the controller, I have 3 actions: attendees, photos, and messages.
How do I achieve the following route schema:
- http://www.site.com/event/{eventname}
- http://www.site.com/event/{eventname}/action/
- http://www.site.com/event/{eventname}/action/{actionid}
Controller will be called EventController, Action can be any of the three actions (attendees, photos, and messages). E.g.
- http://www.site.com/event/ – list all the events
- http://www.site.com/event/autiebirthday/ – show auntibirthday event, in this page there will be links to call photos, messages, and attendees action.
- http://www.site.com/event/autiebirthday/photos/ – list all the photos of auntie birthday event.
- http://www.site.com/event/autiebirthday/photos/1 – show photo with id 1, along with comments.
Thanks.
Rwendi
Route table:
Controller:
Note that I simply used
ViewBagin order to test that the routes work. You should naturally use a proper data source for production.