Note that there are some explanatory texts on larger screens.

plurals
  1. POMultilanguages asp.net mvc site and routing
    primarykey
    data
    text
    <p>I develop multilanguages asp.net mvc site. The language stores in url. The default one will be English. I have BaseController class</p> <pre><code>protected override void OnActionExecuting(ActionExecutingContext filterContext) { string culture = filterContext.RouteData.Values[MvcApplication.CultureParamerName] as string; if (string.IsNullOrWhiteSpace(culture)) culture = Facade.Common.GetLocale(BECulture.Cultures.English);//==en-us Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); base.OnActionExecuting(filterContext); } </code></pre> <p>and some routes</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Photos_Route", "{culture}/photos/{action}/{id}", new { controller = "photos", action = "show", culture = "en-us" } ); routes.MapRoute( "PhotosDownload_Route", "{culture}/photos/{action}/{id}/resolution/{measure1}x{measure2}", new { controller = "photos", action = "download", culture = "en-us" } ); routes.MapRoute( "Pages_Router", "{culture}/page/{id}", new { controller = "home", action = "page", id = UrlParameter.Optional, culture = "en-us" } ); routes.MapRoute( "Tags_Route", // Route name "{culture}/tag/{tag}", // URL with parameters new { controller = "photos", action = "ShowPhotosByTag", culture = "en-us" } // Parameter defaults ); routes.MapRoute( "Home_Route", "{culture}/{action}", new { controller = "home", culture = "en-us" } ); routes.MapRoute( "Default_Route", "{culture}/{controller}/{action}/{id}", new { controller = "home", action = "index", id = 1, culture = "en-us" } ); } </code></pre> <p>I want to do following: if the current language is English then the url must not contain "en-us" value, because the English is default language. And vise-versa: if there's no parameter <code>"culture"</code> in url (that is in <code>RouteData.Values["culture"]</code> ) then the default language is English.</p> <p>How can I do it?</p> <p><strong>UPDATE:</strong> the clarification about what I want. The master page (_Layout.cshtml) contains the link to the page <code>"About site"</code></p> <pre><code> @Html.ActionLink(Resources.Strings.About_LinkText, "about", "home") </code></pre> <p>If the site in English it points to <code>/en-us/about</code>. But I want (if the site in English) it should point to <code>/about</code> (without en-us).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload