I need to pass special characters like #,! etc in URL to Facebook,Twitter and such social sites. For that I am replacing such characters with URL Escape Codes.
return valToEncode.Replace("!", "%21").Replace("#", "%23")
.Replace("$", "%24").Replace("&", "%26")
.Replace("'", "%27").Replace("(", "%28")
.Replace(")", "%29").Replace("*", "%2A");
It works for me, but I want to do it more efficiently.Is there any other way to escape such characters? I tried with Server.URLEncode() but Facebook doesn't render it.
Thanks in advance,
Priya