We have a couple ASP MVC websites just using the standard VS templates default settings - Working as wanted. But now I want to localize these website ( They are now in Dutch and I will add the English language ) I would like to use routing and not Resource because: 1. Languages will differ in content, numbers of pages, etc. 2. The content is mostly text.
I would like the URLs to look some thing like this - www.domain.com/en/Home/Index, www.domain.nl/nl/Home/Index. But the last one should also work with - www.domain.nl/Home/Index - Witch is the exciting URLs.
I have implemented Phil Haacks areas ViewEngine from this blogpost - http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx. But only putting the English website in the areas and keeping the Dutch in old structure. Witch are served as Phils default fallback. But the problem is here that I have to duplicate my controllers for both language's.
So I tried the work method described in this tread - http://stackoverflow.com/questions/1712167/asp-net-mvc-localization-route. It works OK with the ?en? and /nl/ but not with the old URLs.
When using this code in the global.asax the URL without the culture isn't working.
public static void RegisterRoutes(RouteCollection routes)
{
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{culture}/{controller}/{action}/{id}", // URL with parameters
new { culture = "nl-NL", controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"DefaultWitoutCulture", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
I properly overlooking some thing simple but I can't get this to work for me. Or are there a better way of doing this?