开发者

why the following fails

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

An unhandled exception of type 'System.UriFormatException' occurred in System.开发者_C百科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?


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜