Access root url in view "without" culture. V12
# help-with-umbraco
c
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
Why not use a relative Url? Or isnt that an option?
Else you can use the
_httpContext.Request.Host
to get the root url
c
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 😅
a
Loose the tilde 😀
c
😬 going to sink back into my hole now
Hahahaha thank you ❤️
a
Anytime!
2 Views