The example I see everywhere for MVC-style routing is something like this:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add(new Route
(
"Category/{action}/{categoryName}"
, new CategoryRouteHandler()
));
}
What's the reason to pass the RouteTable.Routes collection to RegisterRoutes()? Why not just:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
public static void RegisterRoutes()
{
RouteTable.Routes.Add(new Route
(
"Category/{action}/{categoryName}"
, new CategoryRouteHandler()
));
}
What RouteCollection besides RouteTable.Routes would a route be added to? Isn't RouteTable.Routes the RouteCollection for the web application?
I have a particular IRouteHandler with has a Map() method:
public class ChatRouteHandler : IRouteHandler
{
private static bool mapped;
public void Map()
{
if (!ChatRouteHandler.mapped)
{
RouteTable.Routes.Add
(
new Route("chat/{room}/{date}",
new ChatRouteHandler())
);
}
}
Is there a reason that Map() should accept a RouteCollection and not add to the RouteTable.Routes collection? Again, what other RouteCollection would this IRouteHandler be added to?