System.Uri can't parse when password field contains a "#"
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-03-08T13:20:02Z
Indexed on
2010/03/08
13:36 UTC
Read the original article
Hit count: 716
The following code throws System.UriFormatException:
var uri = new UriBuilder("ftp://user:pass#[email protected]:21/fu/bar.zip");
System.UriFormatException: Invalid URI: A port was expected because of there is a colon (':') present but the port could not be parsed.
Removing the # symbol from the password field solves the issue.
- Is a # symbol a valid character to have in the password field?
- Is there a way to escape this?
- Is this a known bug in the parsing routine of the Uri class?
- How does one get around this - assuming you can't change the password? ;-)
Thanks, Andrew
© Stack Overflow or respective owner