How do I replace all the spaces with %20 in C#?
I want to make a string into a URL using C#. There must be something in the .NET framework that should help, right? LiraNuna I believe you're looking for HttpServerUtility.UrlEncode . System.Web.HttpUtility.UrlEncode(string url) Another way of doing this is using Uri.EscapeUriString(stringToEscape) . Gilda I found useful System.Web.HttpUtility.UrlPathEncode(string str); It replaces spaces with %20 and not with +. To properly escape spaces as well as the rest of the special characters, use System.Uri.EscapeDataString(string stringToEscape) . As commented on the approved story, the