Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:36:49+00:00 2026-05-13T21:36:49+00:00

The following code throws System.UriFormatException: var uri = new UriBuilder(ftp://user:pass#word@ftp.somewhere.com:21/fu/bar.zip); System.UriFormatException: Invalid URI: A

  • 0

The following code throws System.UriFormatException:

var uri = new UriBuilder("ftp://user:pass#word@ftp.somewhere.com: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.

  1. Is a # symbol a valid character to have in the password field?
  2. Is there a way to escape this?
  3. Is this a known bug in the parsing routine of the Uri class?
  4. How does one get around this – assuming you can’t change the password? 😉

Thanks, Andrew

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:36:49+00:00Added an answer on May 13, 2026 at 9:36 pm

    You should be able to use %23 instead.

    The percent symbol followed by a two digit hex number is how characters are escaped in URLs. 23 is the hexadecimal value for the hash/pound symbol in the ASCII table.

    Rather than solving this particular problem, you should solve this problem generally by encoding the whole username and password fields. You should be able to do this with System.Web.HttpUtility.UrlEncode (reference the System.Web assembly):

    string username = ...
    string password = ...
    string url = string.Format("ftp://{0}:{1}@ftp.example.com:21/fu/bar.zip",  HttpUtility.UrlEncode(username),
                                                                               HttpUtility.UrlEncode(password));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code always throws exception .... DataServiceContext ctx = account.CreateCloudTableClient().GetDataServiceContext(); var val =
The following code throws an exception which I have no idea what goes wrong
Can someone tell me why the following code intermittently throws an exception ? I
I have the following code: string hexString = 0x00000004; Type hexType = typeof(Int32); object
I have the following code: public class Tests { public static void main(String[] args)
I'm using the following code to access the Windows Explorer Shell's band site service:
I have .Net 2.0 Windows form containing combobxes. I have written following code to
I'm writing some code to permit users to remotely manage IIS7. Under the bonnet
I am writing an application in C# that reads info from a .mdb file
I'm working on a webapplication which runs central at a company. This webapplication needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.