MVC 入口

1.在 Global.asax

  public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            //入口 1
            AreaRegistration.RegisterAllAreas(); //注册所有区域

            RouteConfig.RegisterRoutes(RouteTable.Routes);//注册路由
            //跳转到RouteConfig  路由配置
            //之后再进过路由调转到控制器
        }
    }

2.在App_Start/RouteConfig.cs

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            //入口2

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
原文地址:https://www.cnblogs.com/enych/p/8889137.html