|
Hi I have a problem with using Uri:s with a mail-address as UserName. Take a look at this code: UriBuilder uriBuild = new UriBuilder(); uriBuild.Scheme = "ftp"; uriBuild.Host = "ftp.host.com"; uriBuild.Path = "path1/path2"; uriBuild.UserName = "name@mail.address.com"; uriBuild.Password = "password"; Console.WriteLine(uriBuild.ToString()); // Output is ftp://name@mail.address.com:password@ftp.host.com/path1/path2 UriBuilder uriBuild2 = new UriBuilder(uriBuild.ToString()); Last line throw an exception: Invalid URI: A port was expected because of there is a colon (':') present but the port could not be parsed And when using it in WebClient.UploadFile also throws same expression. The problem is the @ in the mail-address, if using any username without it everything works. UriBuilder threats the first @ in the Uri as the separation between password and host...but it's not, the second @ is. It doesn't matter if I also provide Port number. |