asp.net mvc 設置啓動頁面在區域中
在開發過程中,我們有時候需要啓動區域中的頁面爲起始頁面,那我們就需要子路由中添加一段代碼
如何完整案例:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Personnal", action = "Index", id = UrlParameter.Optional }
).DataTokens.Add("Area", "PseronnalMenanger");
}
位置:
對應的控制器和action
控制器
對應的視圖:
以上: Test.cshtml 調用 _TestLayout.cshtml
_TestLayou.cshtml