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 





Get url http and redirect url with non ascii character  Get url http and redirect url with non ascii character Reviewed by Leo on Maret 09, 2023 Rating: 5

Tidak ada komentar

About me

About Me

My name is Joanne Doe, a lifestyle photographer and blogger currently living in Osaka, Japan. I write my thoughts and travel stories inside this blog.