I just noticed something in my testing. I was searching for questions tagged "C#" and the questions come back tagged "C".

Code Poet's SOAPI javascript formats the route thusly:


His works, whereas mine includes the "#" even when I HttpUtility.HtmlEncode it. What am I missing, and is there a quick and dirty converter?


2 Answers 2


Use UrlEncode not HtmlEncode.

# is legal in HTML, but a restricted character in URLs.


I will write a test in Soapi.CS to see how it goes. C#<->JS is apples/oranges as the browser is pretty good at taking care of those things.

looks like soapi.cs is not handling it well either.


apparently I am double urlencoding. or maybe i am encoding when I don't need to and the webrequest is encoding it again. I suspect that is the case.

Not sure why you are simply dropping the hash. I will post findings later tonight.

Thanks, Dave. Misreading your question helped me track down a bug in my code! I was encoding each parameter and then again when I build the query.

  • Normally I would agree with you, but if you go to that route in your browser and use the "#" instead of the "%23" you'll get different results. Jul 24, 2010 at 1:11
  • If you try this in StackMobile, you'll see that the '#' is converted to '%23' as per Kevin's answer. The reason I say this is because I made this mistake too originally :) Jul 24, 2010 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .