MVC中如何设置路由指定默认页

MVC中怎么设置默认页,在webform中 只要右键设置起始页就能够,但MVC中却没有这个功能,其实MVC更简单web

以下: url

Login是控制器,Index 是动做 在全局Global.asax中改动下便可

spa

这个是针对area的默认页code

namespaces:默认页的命名空间
DataTokens:该area的键值对
复制代码
routes.MapRoute(

       name: "Default",

       url: "{controller}/{action}/{id}",

       defaults: new { controller = "Index", action = "Index", id = UrlParameter.Optional },

       namespaces: new[] { "MvcWeb.Areas.Members.Controllers" }

   ).DataTokens.Add("Area", "Members");
复制代码

 

[MVC4]App_Start/RouteConfig 原内容orm

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "Login", action = "Index", id = UrlParameter.Optional }
            );  
相关文章
相关标签/搜索