public static string UrlEncode(string url)
{
if (url == null)
return null;
StringBuilder bld = new StringBuilder(url.ToLower());
bld.Replace("!", "%21");
bld.Replace("*", "%2A");
bld.Replace("'", "%27");
bld.Replace("(", "%28");
bld.Replace(")", "%29");
bld.Replace(";", "%3B");
bld.Replace(":", "%3A");
bld.Replace("@", "%40");
bld.Replace("&", "%26");
bld.Replace("=", "%3D");
bld.Replace("+", "%2B");
bld.Replace("$", "%24");
bld.Replace(",", "%2C");
bld.Replace("/", "%2F");
bld.Replace("?", "%3F");
bld.Replace("#", "%23");
bld.Replace("[", "%5B");
bld.Replace("]", "%5D");
return bld.ToString();
}
Tylko że można to zastąpić metodą HttpUtility.UrlEncode
No comments:
Post a Comment