SharePoint: Special characters in query string

I needed to pass the clientName as query string variable. Some of the client names contained special characters like "&'#". Since I was developing for SharePoint 2010, I used SPHttpUtility.UrlPathEncode and it worked perfectly. The code looks something like this:


string clientName = "J.P. Morgan & Chase";
string encodedString = SPHttpUtility.UrlPathEncode(clientName, true);


// Now we can pass the encoded string