1

Not sure why, but when I run the following code

HtmlAnchor bestellenLink = (HtmlAnchor)e.Item.FindControl("bestellenLink");
var uriBuilder = new UriBuilder(Request.Url.AbsoluteUri);
var paramValues = HttpUtility.ParseQueryString(uriBuilder.Query);
paramValues.Add("Test", HttpUtility.UrlEncode("ä"));
uriBuilder.Query = paramValues.ToString();
bestellenLink.HRef = uriBuilder.Uri.ToString();

I get the following output in the bestellenLink.HRef:

http://somedomain/somepage.aspx?Test=%25c3%25a4

While the correct URL encoding of "ä" should be %c3%a4 and not %25c3%25a4. What am I doing wrong?

Thanks, /Francesco

Francesco Gallarotti
  • 1,221
  • 1
  • 16
  • 39
  • 1
    Might be an issue with the HttpUtility.ParseQueryString? http://stackoverflow.com/questions/829080/how-to-build-a-query-string-for-a-url-in-c#comment16989179_1877016 – Troyen May 09 '14 at 09:01
  • Very helpful! I didn't know that... I ended up rewriting the "AppendToQueryString" logic myself without using `ParseQueryString` and now everything works fine!! Thanks! – Francesco Gallarotti May 09 '14 at 12:59

0 Answers0