asp.net web form Cutom Router Handler

Posted by jparram on Stack Overflow See other posts from Stack Overflow or by jparram
Published on 2011-01-07T18:48:20Z Indexed on 2011/01/07 18:54 UTC
Read the original article Hit count: 145

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET