I'm new to ASP.NET MVC, and am following an online tutorial to build a sample project before I build a production project for my internship.
In this project we follow the basic MVC scaffolding, and create two different controllers. The first controller is the default HomeController, which displays a page whether the url be:
- example.com
- example.com/home
- example.com/home/index
I inferred that this was because in the RouteConfig file, the defaults:
argument has listed controller="home", "action="index"
However, after creating my own controller, and mapping a route to it using routes.MapRoute
in the exact same format as the HomeController:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.MapRoute(
name: "Process",
url: "Process/{action}/{id}",
defaults: new { controller = "Process", action = "List", id = UrlParameter.Optional });
The new route only seems to work if I specify example.com/process/list, as opposed to defaulting to example.com/process/list if "/list" was omitted.
Is there something special in the normal HomeController template that defines the same page being returned on different URLs?