title: asp.net web form Custom Router Handler
body: <p>I am using a custom route handler for a webforms application.  I am using routes to determine localization.  ie:
       if the url has <strong><em>es</em></strong> or <strong><em>fr</em></strong> in the route it will load either spanish or french resources. </p>
  
  <p>for example:  </p>
  
  <p>www.someroute/es/checkstuff/checkstuff.aspx </p>
  
  <p>will load:</p>
  
  <p>www.someroute/checkstuff/checkstuff.aspx with the spanish resources.</p>
  
  <p>I am configuring the custom routes in global.asax via:</p>
  
  <pre><code>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)));
          }
      }
  </code></pre>
  
  <p>where _customroutes is a list of routes.</p>
  
  <p>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</p>