protected internal virtual string UrlPathEncode(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }
            int index = value.IndexOf('?');

            if (index >= 0)
            {
                return(this.UrlPathEncode(value.Substring(0, index)) + value.Substring(index));
            }
            return(HttpEncoderUtility.UrlEncodeSpaces(this.UrlEncodeNonAscii(value, Encoding.UTF8)));
        }
Example #2
0
        private static string UrlPathEncodeImpl(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }

            // recurse in case there is a query string
            int i = value.IndexOf('?');

            if (i >= 0)
            {
                return(UrlPathEncodeImpl(value.Substring(0, i)) + value.Substring(i));
            }

            // encode DBCS characters and spaces only
            return(HttpEncoderUtility.UrlEncodeSpaces(UrlEncodeNonAscii(value, Encoding.UTF8)));
        }