首先配置路由文件,默认页是第一个路由的配置:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace WebApplication1 { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "path1", url: "{controller}/{action}/{id}", defaults: new { controller = "Path1", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( name: "path2", url: "{controller}/{action}/{id}", defaults: new { controller = "Path2", action = "Index", id = UrlParameter.Optional } ); } } }