Okay guys, so I've been stuck for at least 2 days, with googling and checking out all other stack articles I could find.
I just want to check to see if the first parameter in my route is a valid culture name, and if it isn't modify the url/route before execution to include a culture value.
Is that so hard?! I don't think it should be.
I could just modify things in a basecontroller class, from which all other controllers inherit, and check there and then modify all route data and send it on its way. The problem lies with some other custom routes I have.
Okay, so here's the problem with my code, and why I think it would be easiest to do before execution of any controllers.
routes.MapRoute(
"Localization",
"{lang}/{controller}/{action}",
new { lang="en-US",controller="Home",action="Index"}
);
routes.MapRoute(
"Solutions",
"{lang}/Solutions/{controller}/{action}",
new { lang="en-US", controller = "WhatWeDo", action = "Index"}
);
routes.MapRoute(
"Default", // Route name
"{lang}/{controller}/{action}/{id}", // URL with parameters
new { lang = "en-US", controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
So, if I try to modify things, I run into this nasty /solutions/ custom route for certain solutions, and for other answers it requires a custom redirect (Yielding a permanently moved error), and checking to see if certain parameters are null.
Is there any way to extract the route data and modify my route/url in the global.asax file? It would be easiest there, and I really would like to just plop it in so that it's always there, and I can just route normally.
I'm probably not making a whole lot of sense, but I'm a bit frustrated. Any suggestions?