Get url http and redirect url with non ascii character
Get url http and redirect url with non ascii character
public IActionResult SetLanguage(string culture, string returnUrl)
{
Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)),
new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(1) }
);
Uri domain = new Uri(Request.GetDisplayUrl());
var server = new Uri(domain.Scheme + "://" + domain.Host + (domain.IsDefaultPort ? "" : ":" + domain.Port));
Uri serverUri = new Uri(server.ToString());
Uri relativeUri = new Uri(returnUrl, UriKind.Relative);
Uri fullUri = new Uri(serverUri, relativeUri);
return RedirectPermanent(fullUri.AbsoluteUri);
//return LocalRedirect(returnUrl);
}
From :
get url https : https://stackoverflow.com/questions/59595994/how-can-i-get-the-current-url-protocol-in-the-mvc-controller
Create new Uri : https://stackoverflow.com/questions/2887924/invalid-uri-the-format-of-the-uri-could-not-be-determined
redirect url non ascii : https://www.edinkapic.com/2020/02/http-redirect-with-non-ascii-characters-in-the-url.html
Tidak ada komentar