public IActionResult Index() { if (SetupHelper.IsDbCreateComplete && SetupHelper.IsAdminCreateComplete) { if (GlobalContext.SetupConfig == null) { GlobalContext.SetupConfig = SetupHelper.LoadSetup(); } var setupConfig = GlobalContext.SetupConfig; if (setupConfig == null) { TempData["ErrorMessage"] = "Setup config file is missed. Please reinstall."; return(Redirect("~/CmsHome/ResourceNotFound")); } if (setupConfig.StartupData.Trim('/') == "" || setupConfig.StartupData.Trim().ToLower() == "/home") { return(View()); } var langEnabledUrl = NccUrlHelper.AddLanguageToUrl(CurrentLanguage, NccUrlHelper.EncodeUrl(setupConfig.StartupUrl)); return(Redirect(langEnabledUrl)); } return(Redirect("/SetupHome/Index")); }
public IActionResult SetLanguage(string culture, string returnUrl) { culture = culture.ToLower(); Response.Cookies.Append( CookieRequestCultureProvider.DefaultCookieName, CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)), new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(1) } ); returnUrl = WebUtility.UrlDecode(returnUrl); if (!string.IsNullOrEmpty(returnUrl) && returnUrl.Length > 4) { if (!IsContainsLangPrefix(returnUrl)) { returnUrl = culture + returnUrl; } if (!IsStartedWithCurrentCulture(returnUrl, culture)) { if (returnUrl.StartsWith("/")) { returnUrl = returnUrl.Substring(3); } else { returnUrl = returnUrl.Substring(2); } returnUrl = culture + returnUrl; } } if (returnUrl.StartsWith("/") == false) { returnUrl = "/" + returnUrl; } returnUrl = NccUrlHelper.EncodeUrl(returnUrl); return(Redirect(returnUrl)); }
public void NccUrlHelper_Url_encode_should_skip_url_seperators() { var encUrl = NccUrlHelper.EncodeUrl("https://localhost:44346/bn/Post/টেস্ট-পোস্ট-1"); Assert.Equal("https://localhost:44346/bn/Post/%e0%a6%9f%e0%a7%87%e0%a6%b8%e0%a7%8d%e0%a6%9f-%e0%a6%aa%e0%a7%8b%e0%a6%b8%e0%a7%8d%e0%a6%9f-1", encUrl); }