예제 #1
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.LowercaseUrls = true;
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add(new LowercaseRoute(
                url: "Assets/{action}/{id}",
                defaults: new RouteValueDictionary(new { controller = "Assets", action = "Index", id = UrlParameter.Optional }),
                routeHandler: new MvcRouteHandler()));
            routes.Add(new LowercaseRoute(
                url: "File/{id}/{type}/{hash}",
                defaults: new RouteValueDictionary(new { controller = "File", action = "Index" }),
                routeHandler:new MvcRouteHandler()));
            routes.Add(new Route(
                url: "r/e",
                defaults: new RouteValueDictionary(new { controller = "Redirect", action = "External" }),
                routeHandler:new MvcRouteHandler()));
            routes.Add(new Route(
                url: "r/i",
                defaults: new RouteValueDictionary(new { controller = "Redirect", action = "Internal" }),
                routeHandler:new MvcRouteHandler()));
            var valuesConstraint = new ExpectedValuesConstraint(LanguageTypeHelper.Instance.GetIsoNames());
            routes.Add(new LowercaseRoute(
                url: "{language}/{controller}/{action}/{id}",
                defaults: new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional }),
                routeHandler: new MvcRouteHandler(),
                constraints: new RouteValueDictionary(new { language = valuesConstraint })));
            routes.MapRoute(
                name: "NoLanguage",
                url: "{any1}/{any2}/{any3}/{any4}",
                defaults: new { controller = "home", action = "detectlanguage", any1 = UrlParameter.Optional, any2 = UrlParameter.Optional, any3 = UrlParameter.Optional, any4 = UrlParameter.Optional, }
            );
        }
예제 #2
0
 public override void RegisterArea(AreaRegistrationContext context)
 {
     var valuesConstraint = new ExpectedValuesConstraint(LanguageTypeHelper.Instance.GetIsoNames());
     context.MapRoute(
         url: "{language}/Moderate/{controller}/{action}/{id}",
         defaults: new RouteValueDictionary(new { controller = "Moderate", action = "Index", id = UrlParameter.Optional }),
         constraints: new RouteValueDictionary(new { language = valuesConstraint }),
         name: "Moderate_default",
         namespaces: new [] { "Project_B.Areas.Moderate.Controllers" });
 }