Getting Right Encoding From HTTPContext
I am trying to build site titles generated dynamically from HTTPContext , but I saw that I have problems when url contains special characters like
ß which results in titles having wrong characters for instance
fußball translates into
fu%C3%9Fball. Right now I store my title in array like that:
string customSEOTitle = HttpContext.Current.Request.Url.AbsolutePath .Split('/') .Where(s => !string.IsNullOrWhiteSpace(s)) .Distinct() .Select(s => CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s)) .ToArray();
The thing is that AbsolutePath returns
fu%C3%9Fball when the url is actually
fußball. I saw that
RawUrl gets right characters , but it does take query string also which I don't want.Is there any generic and straightforward way to do this or I have to write extension method striping query string?
What you might be looking are UrlEncode and UrlDecode methods.
Not sure which .NET version you use, see elaborate discussion here.
- → How to Fire Resize event after all images resize
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → Getting right encoding from HTTPContext
- → How to create a site map using DNN and C#
- → I want integrate shopify into my mvc 4 c# application
- → Bootstrap Nav Collapse via Data Attributes Not Working
- → Shopify api updating variants returned error
- → ASP.NET C# SEO for each product on detail page on my ECOMMERCE site
- → SEO Meta Tags From Behind Code - C#
- → How to implement search with two terms for a collection?