SPEncode.UrlEncode returns %2b instead of %20
Posted: 10/08/2010 Filed under: Development | Tags: API, Development Leave a comment »SharePoint URL empty spaces are translated as %20. Hence, in order to ensure that are URL’s are reference correctly we would use the UrlEncode method of the SPEncode class. Be aware though, that this will return %2b instead of %20 as we would have been hoping for. In order to get around this and still have my URL’s reference correctly I use the string Contains and string Replace methods. Code snippet as below:
private string fullUrl = “<some url>”
if(fullUrl.Contains(“ ”))
{
fullUrl.Replace(“ ”, “%20”);
return fullUrl;
}