ASP.NET MVC 设置Area中 Controller 的方法 默认启动页

MVC中通常分区域编程,互不干扰,如果需要设置某个区域下面的某个控制器下面的某个方法为默认启动页的话,直接修改项目的路由如下:

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "UserInfo", action = "Index", id = UrlParameter.Optional },
                namespaces: new string[] { "要设置Controller的命名空间" }
            ).DataTokens.Add("Area", "区域名称");
        }

 修改默认路由后即可正常访问!!!

原文地址:https://www.cnblogs.com/DONET-LC/p/6208139.html