WCF UriTemplate Strips Some UrlEncoded characters from bound path segment - by Lord Zoltan

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 413312 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 2/10/2009 6:51:41 AM
Access Restriction Public


I've been following the very helpful MSDN guide on designing RESTful services with WCF, and have had great success with it.

However, I've noticed some strange behaviour with urlencoded characters - '#' encoded to %23, for example, which when specified in a path segment that is bound to a parameter will be stripped out; but when bound to a query string parameter will be read normally.

So, given my uri template of:


And a matched URL of


The 'search' parameter in the WCF method receives the value 'c', not 'c#'.

However, this uri template:


Bound to this uri:


Works fine.

Finally, this stripping behaviour only happens on certain characters - if I use the Path-centric version of the template, and fire this URL at it:


The parameter is deserialised correctly to 'Visual Basic'
Sign in to post a comment.
Posted by davija001 on 9/2/2010 at 2:25 PM
Yeah, where is the fix if this has been fixed? I am currently still able to reproduce this in the latest fully-patched .net 3.5 SP1.
Posted by Marius Serban on 7/11/2010 at 10:00 AM
The issue is reproduced also with ASP.NET MVC1. An url like http;//localhost/tag/c# returns only "c" as the value. If Url.Encode is being used then a double encoding happens - the url becomes : http://localhost/tag/c%2523.

Is there any workaround for this issue?
Posted by AnonymousManThing on 7/1/2010 at 9:14 AM
Also having problem with .net 3.5 SP1.
Posted by Lei_homs on 6/22/2010 at 12:02 PM
I'm using .net 3.5 SP1 and still having this issue. Can you tell us what we need to do to fix the problem?
Posted by Microsoft on 2/27/2009 at 3:18 PM
Thank you for submitting this issue. Upon investigation, it seems that this is happening because %23 is being incorrectly interpreted as its decoded value, which is the "#" delimeter which has special meaning in URLs. So, a URL like:
Will be interpreted as:
Which is equivalent to:
It seems that this bug is at a deeper level than WCF, since regular ASP.NET pages also seem to be affected, and the bug does not go away when self-hosting the WCF service instead of going through IIS/ASP.NET. In any case, I've logged this bug in our product database to consider fixing in a future version.
Posted by Microsoft on 2/10/2009 at 6:03 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com/)