G
Guest
I have noticed that System.Web.HttpUtility.UrlEncode() encodes spaces as plus
signs (+) rather than the hex encoded "%20". Why?
In most cases, this is not a problem, but it breaks fragments. For example,
if you created the following on a page <a name="example fragment">example</a>:
"http://www.example.com/index.htm#example+fragment" will not jump down to
the proper area of the page
"http://www.example.com/index.htm#example fragment" works as expected
(I have tested this in IE6 and Firefox 1.0.1 on WinXP)
While using a plus sign when creating your own URLs is valid, the proper way
to replace a space in a URL is to use "%20", so this seems to be a .NET bug.
signs (+) rather than the hex encoded "%20". Why?
In most cases, this is not a problem, but it breaks fragments. For example,
if you created the following on a page <a name="example fragment">example</a>:
"http://www.example.com/index.htm#example+fragment" will not jump down to
the proper area of the page
"http://www.example.com/index.htm#example fragment" works as expected
(I have tested this in IE6 and Firefox 1.0.1 on WinXP)
While using a plus sign when creating your own URLs is valid, the proper way
to replace a space in a URL is to use "%20", so this seems to be a .NET bug.