I am working on an ASP.NET MVC project were I am using routing to produce friendly URLs and have an issue I am not sure how best to solve.
The routing I have setup work like the following
{category}
{category}/{manufacturer}
{category}/{manufacturer}/{product}
The problem I have is that I want to display matches to the same route in differing ways. e.g.
Category1 Displays
- A Description followed by
- An Image followed by a
- List of Products
Category2 Displays
- An Image followed by
- Promotions followed by a
- Description
I have got round this by having an enum ViewTemplate associated with the category and then return the view with the same name, but this doesn't feel right, firstly because I'm not sure I should be logic like this in the controller action and also I am still making the same database calls which is fine for some stuff but if a category has 500 products I am still pulling them out the database even for the Category2 when they won't be used. Now to the point:
- Is return different views from the same controller action wrong?
- How would you deal with loading different data for each view?
- If I am wrong (which I think I am) How should I be doing something like this?
Thanks for any help you could be.