Is there any easy way to convert email address string into proper URI format?
Input:
http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/[email protected]
Output should be:
http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/myemail%40yahoo.com
If I didn't do the output, I get an error response like
An Error Was Encountered
The URI you submitted has disallowed characters.
Thanks in advance !
You have to extract your QueryString from the url, encode them and build the new url.
string url = "http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/[email protected]";
int index = url.LastIndexOf("/");
string queryString = url.Substring(index + 1, url.Length - (index + 1));
url = url.Substring(0, index) + "/" + HttpUtility.UrlEncode(queryString);
// url is now
// http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/myemail%40yahoo.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With