Reputation: 99
It definitely has been asked many times, but offered solutions does not seem to work.
Input:
sample text
Output:
sample%20text
I'm using suggested HttpUtility.UrlEncode()
but instead of desired output it returns:
sample+text
Am i doing something wrong, or this method is no longer valid?
Upvotes: 1
Views: 13566
Reputation: 91
Try this:
string str = "sample text";
string url = Uri.EscapeDataString(str);
Upvotes: 5