Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 public RedirectToLozalizedRoute(bool useCurrentCultureLangauge, string defaultLanguage)
     : base(ControllerActionId, new MvcRouteHandler())
 {
     _useCurrentCultureLangauge = useCurrentCultureLangauge;
     _defaultLanguage           = defaultLanguage;
     if (string.IsNullOrWhiteSpace(_defaultLanguage))
     {
         _defaultLanguage = MvcUrlExtension.GetCultureTwoDigit();
     }
     Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional });
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            var data = base.GetRouteData(httpContext);

            if (data == null)
            {
                return(null);
            }

            var lang = data.Values[MvcUrlExtension.LanguageRouteKey];

            if (lang == null)
            {
                string language = _defaultLanguage;
                if (_useCurrentCultureLangauge)
                {
                    language = MvcUrlExtension.GetCultureTwoDigit(language);
                }
                data.Values[MvcUrlExtension.LanguageRouteKey] = language;

                RedirectToLocalizedLocation(httpContext, language);
            }
            return(data);
        }