public static string UrlEncode(string urlToEncode) { if (string.IsNullOrEmpty(urlToEncode)) return urlToEncode; return HttpUtility.UrlEncode(urlToEncode).Replace("'", "%27"); }