是否可以拥有这样的路线: www.MyDomin / AnyPage www.MyDomin / AnyPage1等等?而不是www.MySite / MyController / AnyPage
不指定控制器?
答案 0 :(得分:0)
您可以定义以下路线:
routes.MapRoute(
"Default",
"{page}",
new { controller = "Home", action = "Index", page = UrlParameter.Optional }
);
现在剩下的就是它将映射的控制器动作:
public class HomeController: Controller
{
public ActionResult Index(string page)
{
...
}
}
答案 1 :(得分:0)
是的。在Global.asax文件中编辑路由,例如:
routes.MapRoute(
"MyTerrificRoute",
"{action}",
new { controller = "MyController", action = "Index" }
);