我今天问了很多问题,但无论如何,我安装了一个名为Twitter bootstrap for asp.net mvc 4 sample
我的默认 mvc4 空项目的包。老实说,它看起来比默认模板好得多。安装此模板会添加一些控制器、css 文件等。它添加了一个ExampleLayoutsRouteConfig.cs
看起来像这样
public class ExampleLayoutsRouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapNavigationRoute<HomeController>("Customers", c => c.Index());
routes.MapNavigationRoute<AccountController>("Hardware", c => c.Login());
routes.MapNavigationRoute<ExampleLayoutsController>("Profile", c => c.Starter())
.AddChildRoute<ExampleLayoutsController>("Change Password", c => c.Marketing())
.AddChildRoute<AccountController>("Add User", c => c.Register())
.AddChildRoute<ExampleLayoutsController>("Logout", c => c.SignIn())
;
}
}
使我的导航菜单看起来像这样
是否可以根据用户角色访问我的某些路线或子路线?就像是
routes.MapNavigationRoute<ExampleLayoutsController>("Profile", c => c.Starter())
.AddChildRoute<ExampleLayoutsController>("Change Password", c => c.Marketing())
//can only be accessed by admin
.AddChildRoute<AccountController>("Add User", c => c.Register())
.AddChildRoute<ExampleLayoutsController>("Logout", c => c.SignIn())
;