开发者

localized routes solution

开发者 https://www.devze.com 2023-04-06 16:03 出处:网络
I built a french/english app and I would like to use the same controller/view for both language but to have a different route that is map to the current language. Let say I have website.com/Account/Re

I built a french/english app and I would like to use the same controller/view for both language but to have a different route that is map to the current language. Let say I have website.com/Account/Register that return to my Account controller and Register action, I would love to have a route that is website.com/Comptes/Inscription. I know that I can add a custom route in the RegisterRoute section like so :

routes.MapRoute(
                "AccountFr", // Route name
                "comptes/inscription", // URL with parameters
                new { controller = "Account", action = "Register" } // Parameter defaults
            );

But it will need a lot of [boring] code to write all the possibles routes and also, I think it won't work when I will use T4MVC as @Url.Action(MVC.Account.Register()) will return /Account/开发者_Go百科Register no mater if I'm in french or in english.

Anyone as suggestions/ideas for this problem?

Thanks!

EDIT

Since it does not seem to have a good solution using T4MVC does anyone have an other good solution?


Unfortunately, this won't easily work with T4MVC. The root of the problem is that when going through T4MVC, you can't pick a specific route. Instead, the route gets selected based on the Controller, action and parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号