Reputation: 25141
If i were to create a really really simple MVC3 web app, with the pages
http://localhost/home, http://localhost/b and http://localhost/c, does this mean creating three seperate controllers?
I was hoping to route all three through one controller with a seperate 'ActionResult' for each.
Thanks.
Upvotes: 2
Views: 112
Reputation: 1922
Yeah you can add routes and use the same controller.
But I like my controllers to represent related work. So for example an account controller would have a login, registeration and signup. CustomerController might have list, create, edit, delete.
Upvotes: 0
Reputation: 4988
You can do that by adding a route for each URL to the same controller and different actions.
http://www.asp.net/mvc/tutorials/creating-custom-routes-cs
Example:
routes.MapRoute( "home", "{action}",
new { controller = "Home", action = "Index", id = "" });
That will route to actions called "home" "b" and "c".
Although I wouldn't do it. I tend to always have a controller and action as it makes categorisation of concerns easier later.
Upvotes: 6