0
 Uri test = new Uri("http%3A%2F%2F100.100.1.1%3A8080"); 

An unhandled exception of type 'System.UriFormatException' occurred in System.dll

Additional information: Invalid URI: The format of the URI could not be determined.

Anyone know why I cannot pass in a URL encoded string to the constructor of Uri?

1
  • 1
    The encoding is meant for the querystring data, not the URL itself. Commented Dec 9, 2010 at 9:18

3 Answers 3

2

Do not escape it and try using http://100.100.1.1:8080.

Sign up to request clarification or add additional context in comments.

Comments

1

The Uri Constructor requires the String to be a valid RFC2396 URI. There's this Uri.CheckSchemeName Method to check if your passed URI is valid.

Comments

0

Are you missing a % before the second 2F? Try passing the string through a URL un-encoder and make sure the result is what you expected.

1 Comment

@user496949: Ah, ok, no problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.