I need to pass special characters like # ,! etc. in the URL of Facebook, Twitter, and such social sites. To do this, I replace these characters with the URL code Escape.
return valToEncode.Replace("!", "%21").Replace("#", "%23")
.Replace("$", "%24").Replace("&", "%26")
.Replace("'", "%27").Replace("(", "%28")
.Replace(")", "%29").Replace("*", "%2A");
This works for me, but I want to do it more efficiently. Is there any other way to avoid such characters? I tried with Server.URLEncode () , but Facebook does not display it.
Thanks in advance,
Priya
source
share