/
RouteConfig.cs
77 lines (63 loc) · 3.2 KB
/
RouteConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.Globalization;
using System.Web.Mvc;
using System.Web.Mvc.Routing.Constraints;
using System.Web.Routing;
using Kentico.Web.Mvc;
using Kentico.Activities.Web.Mvc;
using Kentico.Newsletters.Web.Mvc;
using DancingGoat.Infrastructure;
namespace DancingGoat
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var defaultCulture = CultureInfo.GetCultureInfo("en-US");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Map routes to Kentico HTTP handlers first as some Kentico URLs might be matched by the default ASP.NET MVC route resulting in displaying pages without images
routes.Kentico().MapRoutes();
// Map Kentico Activities routes
routes.Kentico().MapActivitiesRoutes();
routes.Kentico().MapOpenedEmailHandlerRoute();
routes.Kentico().MapEmailLinkHandlerRoute();
var route = routes.MapRoute(
name: "Article",
url: "{culture}/Articles/{id}/{pageAlias}",
defaults: new { culture = defaultCulture.Name, controller = "Articles", action = "Show" },
constraints: new { culture = new SiteCultureConstraint("DancingGoatMvc"), id = new IntRouteConstraint() }
);
// A route value determines the culture of the current thread
route.RouteHandler = new MultiCultureMvcRouteHandler(defaultCulture);
route = routes.MapRoute(
name: "Store",
url: "{culture}/Store/{controller}",
defaults: new { culture = defaultCulture.Name, action = "Index" },
constraints: new { culture = new SiteCultureConstraint("DancingGoatMvc"), controller = "Coffees|Brewers" }
);
// A route value determines the culture of the current thread
route.RouteHandler = new MultiCultureMvcRouteHandler(defaultCulture);
route = routes.MapRoute(
name: "Product",
url: "{culture}/Product/{id}/{productAlias}",
defaults: new { culture = defaultCulture.Name, controller = "Product", action = "Detail" },
constraints: new { culture = new SiteCultureConstraint("DancingGoatMvc"), id = new IntRouteConstraint() }
);
// A route value determines the culture of the current thread
route.RouteHandler = new MultiCultureMvcRouteHandler(defaultCulture);
route = routes.MapRoute(
name: "Default",
url: "{culture}/{controller}/{action}",
defaults: new { culture = defaultCulture.Name, controller = "Home", action = "Index" },
constraints: new { culture = new SiteCultureConstraint("DancingGoatMvc") }
);
// A route value determines the culture of the current thread
route.RouteHandler = new MultiCultureMvcRouteHandler(defaultCulture);
// Display a custom view when no route is found
routes.MapRoute(
name: "NotFound",
url: "{*url}",
defaults: new { controller = "HttpErrors", action = "NotFound" }
);
}
}
}