I'm new to ASP.NET MVC and I've encountered problem, which I can't solve. I've spent two days searching Google, but still nothing.
So, my situation is: I'm trying to implement localization in my ASP.NET MVC application using routing.
www.mysite.com/Home/Index
- for default (Russian)
www.mysite.com/en/Home/Index
- for English
So I'm registering routes:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
"Default",
"{controller}/{action}",
new { controller = "Home", action = "Index"},
new { controller = "^[a-zA-z]{4,}$" }
);
routes.MapRoute(
"Localization",
"{lang}/{controller}/{action}",
new { lang = "en", controller = "Home", action = "Index" }
);
}
Navigating to default: www.mysite.com/Home/Index
works fine.
But when I try to navigate to www.mysite.com/en/Home/Index
I get 404 error
.
What is more interesting, RouteDebugger
does'n see my new route:
Adding more new routes, changing the order of their mapping or even deleting all my routes do nothing.
It seems that route {controller}/{action}/{id}
is just the default route for MVC which was added "before me".
So, what could be the problem? I have totally no idea! I've seen screenshots of Rote Debugger from other sites and their routes are displayed. For example some other site: Screenshot
Maybe I have to change something in web.config
? I'm completely confused. Please help!
Thank you very much for your time!