I’d like to achieve the following (with ASP.NET MVC 3):
A controller called “apps” with the following actions:
- /apps/my
- /apps/agency
- /apps/new
Within the last action I really want some sub-actions, e.g.:
- /apps/new/product
- /apps/new/tariff
I could write the New() action to take some kind of parameter to say which view I should render (i.e. product or tariff) but that feels a bit dirty.
What I really want is separate action methods for product and tariff.
What’s the best way to go about this?
I think I could use Areas but this seems overkill for what I want – is the solution just to write a custom route?
Many thanks!
Sam
You could use Areas but for this small amount I agree that it is probably overkill. I’d say making the New action take in a parameter is fine for what you need. It may get more complicated if you want to pass more information in but its still do able. If you want to keep the code clean(er) you can have the action do all the complicated bits in separate private methods.
However, doing it with a custom route way (and with a separate controller as well) …
Global.asax.cs
The add a controller (NewAppsController).
Hope this helps.