asp.net web form Cutom Router Handler
- by jparram
I am using a custom route handler for a webforms application. I am using routes to determine localization. ie:
if the url has es or fr in the route it will load either spanish or french resources.
for example:
www.someroute/es/checkstuff/checkstuff.aspx
will load:
www.someroute/checkstuff/checkstuff.aspx with the spanish resources.
I am configuring the custom routes in global.asax via:
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
foreach (var value in _customRoutes)
{
routes.Add(value.RouteName, new Route(value.Route, new CustomRouteHandler(value.ResolvedRoute)));
}
}
where _customroutes is a list of routes.
Is there a way to do this with some kind of pattern matching so I can avoid adding a specific route for each page in the application. While I know I could use a t4 template to generate the routes, I guess I am looking for a dynamic way to create the list