You can easily write code in your example as follows:
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); RouteTable.Routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); }
However, as the volume of the necessary configuration grows, it makes sense to break it into several logically connected pieces. ASP.NET MVC supports this quite well, and the default project template is simply trying to help you with this.
millimoose
source share