I'm using ASP.NET MVC 4, .NET 4.5. Any way, besides creating individual controllers for each "action", to have "controller-less" urls?
What I mean is, have a Home controller filled with actions. Urls such as:
to become
but still use the Home controller.
You can / will absolutely have multiple Views from a Controller. Just think about creating a model for each view if you want to stick up with MVC pattern. Save this answer.
A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.
You can define routes that don't contain the controller name like this:
routes.MapRoute(
"About", // Route name
"About/", // URL with parameters
new { controller = "Home", action = "About" } // Parameter defaults
);
routes.MapRoute(
"Contact", // Route name
"Contact/", // URL with parameters
new { controller = "Home", action = "Contact" } // Parameter defaults
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With