using System; using System.Web.Routing; using System.Web.Mvc; using System.Reflection; namespace RouteTesterDemoWeb { public class GlobalApplication : System.Web.HttpApplication { public void RegisterRoutes(RouteCollection routes) { routes.Add(new Route("foo/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller="Home", action = "Index", id = (string)null }), }); routes.Add(new Route("bar/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller="Home", action = "Index", id = (string)null }), }); routes.Add(new Route("{action}/{controller}/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { action = "Index", id = (string)null }), }); routes.Add(new Route("Default.aspx", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = (string)null }), }); } protected void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); } } }