首先,设置你的意见:
Views\
Company\
Index.aspx
About.aspx
Mission.aspx
AnotherAction.aspx
在你GlobalAsax.RegisterRoutes(RouteCollection路线)方法:
public static void RegisterRoutes(RouteCollection routes)
{
// this will match urls starting with company/about, and then will call the particular
// action (if it exists)
routes.MapRoute("mission", "company/about/{action}",
new { controller = "Company"});
// the default route goes at the end...
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
在控制器:
CompanyController
{
public ViewResult Index() { return View(); }
public ViewResult About() { return View(); }
public ViewResult Mission() { return View(); }
public ViewResult AnotherAction() { return View(); }
}