I am creating an application where client-side functionality calls various services to return results/content etc. At the moment, I have 3 controllers, with their actions which is working fine. What I’m trying to decide is how to manage list content, i.e. in 2 instances, there will be JSON lists of drop-down data outlined below:
In one page, there would be a dropdown that needs to call a list of e.g. Car Makes. Once selected a make, another call to then return two additional arrays of e.g. Car products etc. In another page, there is just one call to return two arrays of products. The common theme is that it is essentially list management.
At the moment, I have my controllers setup as:
ExistingMember
Switcher
NewMember
Switcher requires a list of CarMakes, and then associated call to get products.
ExistingMember requires a list of Products.
What is the best way to setup my Controller/Action/id?
I have toyed with various options:
- /Switcher/CarMakes
- /Switcher/CarProducts/7
- /ExistingMember/Products
Also modifying routes for brevity:
- /{controller}/List/{action}/{id}
- /Switcher/List/CarMakes
- /Switcher/List/CarProducts/7
Or moving to a dedicated list controller
- /List/CarMakes
- /List/CarProducts/7
- /List/Products
How you define your routes and overall controller architecture is pretty subjective but I usually give out the same advice for questions like this:
Do what makes sense to you and your team.