0

I'm trying to change the way our actionresult names appear on the URL.

I tried using [ActionName()] attribute on the actionresult declaration and modifying routes.Maproute() parameters in RouteConfig but it just caused application errors. Apparently, I'm missing something or doing it all wrong.

Simply, I'm trying to make the following actionresult appear as "giris" on url.

public ActionResult Login(string returnUrl, string lang = "tr")
{
    code code code
}

and this is the part about this actionresult

routes.MapRoute(
    "LoginTr",
    "login",
    new { controller = "Account", action = "Login", lang = "tr" }
);
routes.MapRoute(
    "LoginEn",
    "en/login",
    new { controller = "Account", action = "Login", lang = "en" }
);

Also how can I make the custom url's work for different page languages?

Ege Bayrak
  • 1,139
  • 3
  • 20
  • 49
  • Do you mean you want the urls to be `.../giris` and `.../en/giris` respectively? –  Aug 15 '17 at 08:12
  • actually /en URL's will remain to be in English so it should keep being /en/login. I don't know how to handle this since they map to same actionresult – Ege Bayrak Aug 15 '17 at 08:18
  • Refer [these answers](https://stackoverflow.com/questions/2146227/how-to-route-a-multiple-language-url-with-a-mvc) for some options –  Aug 15 '17 at 08:24
  • My main problem of not making them appear with custom names still persists, different language is next part. – Ege Bayrak Aug 15 '17 at 08:28
  • @EgeBayrak did you try to use Login(string returnUrl, string lang = "tr", string keyword = "giris") and [Route("/{lang}/{keyword}")] – hasan Aug 15 '17 at 09:59
  • If you want to translate URLs to multiple languages, you can use [RouteLocalization](https://github.com/Dresel/RouteLocalization) to do it (or reverse-engineer the bits you need). Keep in mind, URLs are just cosmetic just like every other part of the UI, so they can exist in resource files just like other content. – NightOwl888 Aug 15 '17 at 21:27

0 Answers0