Hey all, Just trying to build a quick language switcher for a V12 site utilising culture variants.
Part of our language switcher intends to use a little flag icon from the wwwroot folder, but for the life of me I cant figure out how to access the Root URL "Without" the culture attached to build the URL for this flag svg.
I thought it would be the case of passing into the Url() method "culture = null" but this still returns the current culture of the site.
Any ideas how I can access the root url without the culture segment?
a
Ambert
08/11/2023, 8:29 AM
Why not use a relative Url? Or isnt that an option?
Ambert
08/11/2023, 8:29 AM
Else you can use the
_httpContext.Request.Host
to get the root url
c
Chancer
08/11/2023, 8:33 AM
I did try creating a relative url like so:
Copy code
html
var flagUrl = $"~/assets/{c.TwoLetterISOLanguageName}.svg";
<img src="@flagUrl" /></a>
But this ended up creating a url to:
"https://localhost:44375/en/~/assets/en.svg"
So perhaps I was doing something wrong there 😅