#Access root url in view "without" culture. V12

1 messages · Page 1 of 1 (latest)

solar anchor
#

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?

halcyon estuary
#

Why not use a relative Url? Or isnt that an option?

#

Else you can use the _httpContext.Request.Host to get the root url

solar anchor
#

I did try creating a relative url like so:

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 😅

halcyon estuary
#

Loose the tilde 😀

solar anchor
#

😬 going to sink back into my hole now

#

Hahahaha thank you ❤️