I have an issue in Unified Search when using Track(). If I open a search result that is a shortcut that redirects to a different url, and the search string contains Norwegian letters ('æ', 'ø' or 'å'), then I get an error, telling me it's not allowed with these characters in the header.
I wonder if there are some issues with Track()? And I cannot find a built-in way to make sure the url is encoded.
I made this code to fix the problem, but I'm thinking this probably shouldn't be necessary:
public void EncodeSearchQueryParameter(UnifiedSearchHit searchHit)
{
if (string.IsNullOrWhiteSpace(searchHit.Url)) return;
var uri = new Uri(searchHit.Url);
var query = HttpUtility.ParseQueryString(uri.Query);
var originalQuery = query["_t_q"];
if (!string.IsNullOrEmpty(originalQuery))
{
query["_t_q"] = Uri.EscapeDataString(originalQuery);
}
var baseUrl = uri.GetLeftPart(UriPartial.Path);
var newQuery = query.ToString();
var newUrl = $"{baseUrl}?{newQuery}";
searchHit.Url = newUrl;
}
Hi,
I have an issue in Unified Search when using Track(). If I open a search result that is a shortcut that redirects to a different url, and the search string contains Norwegian letters ('æ', 'ø' or 'å'), then I get an error, telling me it's not allowed with these characters in the header.
I wonder if there are some issues with Track()? And I cannot find a built-in way to make sure the url is encoded.
I made this code to fix the problem, but I'm thinking this probably shouldn't be necessary: