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 267703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:35:36+00:00 2026-05-11T23:35:36+00:00

This is related to another open question of mine . While there aren’t any

  • 0

This is related to another open question of mine. While there aren’t any actual answers, dtb started me down this track so if it bears fruit I’ll be accepting his answer.

I’m generating an announce url for a BitTorrent tracker in some (fairly hairy) C# code.

The end result is something like:

http://208.106.250.207:8192/announce?info_hash=-%CA8%C1%C9rDb%ADL%ED%B4%2A%15i%80Z%B8%F%C&peer_id=01234567890123456789&port=6881&uploaded=0&downloaded=0&left=0&compact=0&no_peer_id=0&event=started

If I copy paste this into an address bar, I get a valid response from the tracker. However, my code is getting an error message back (invalid info_hash).

The code dispatching the request:

... Code building the URI ...
String uri = BuildURI(); //This results in the above URI string.
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
req.Proxy = new WebProxy();  //Some examples online suggest this is required, so WARNING: here be voodoo (determine if necessary later)
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
... Code parsing the stream ...

If I debug and pull out the string version of req.RequestUri, I get:

http://208.106.250.207:8192/announce?info_hash=-Ê8ÁÉrDb­Lí´*iZ¸%25F%25C&peer_id=01234567890123456789&port=6881&uploaded=0&downloaded=0&left=0&compact=0&no_peer_id=0&event=started

I can’t actually tell what’s being sent to the tracker “on the line”, but it looks like I’m doing something dumb with regard to URIs. Anyone know what?

  • 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-11T23:35:36+00:00Added an answer on May 11, 2026 at 11:35 pm

    Use .AbsoluteUri from a System.Uri (being the Type of Request.RequestUri) to get your original url without it being “munged”

    The “problem” here is the way the .Net System.Uri class works (I say “problem” in quotes, because it is actually behaving correctly).

    Your original info_hash querystring is a load of url-encoded bytes. When you retrieve the Uri instance using Uri.ToString(), it helpfully decodes these (by doing a url-decode) and converts these bytes (e.g. %CA) into their respective characters (in your case Ê, but this is probably dependent on your local code page settings as this is an “upper-half” ANSI character and will change depending on code-page).

    Internally, the querystring is actually being stored correctly; the System.Uri class is just trying to be helpful.

    This bit of code should illustrate it better:

     string myUrl = "http://208.106.250.207:8192/announce?info_hash=-%CA8%C1%C9rDb%ADL%ED%B4%2A%15i%80Z%B8%F%C&peer_id=01234567890123456789&port=6881&uploaded=0&downloaded=0&left=0&compact=0&no_peer_id=0&event=started";
    
                Uri myUri = new Uri(myUrl);
                Console.WriteLine("ToString: " + myUri.ToString());
                Console.WriteLine("Query: " + myUri.Query);
                Console.WriteLine("AbsoluteUri: " + myUri.AbsoluteUri);
    

    I’d guess that, on the wire, things are fine and this is just an artifact of how you’re retrieving the url from System.Uri.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to another question of mine. Thanks to some help I
This is closely related to another question I asked: Is there functionality that is
This is related to another Delphi-version question but still different; I'm looking for a
This question is related to another question I wrote: Trouble using DOTNET from PHP.
This question is related to another question, where I wanted to define a custom
This is actually related to another question I had that was already answered. That
This question is related to another question I asked Basically, I have 2 horizontally
This question is related to another question I just posted . I'm prepping for
Another question related to this one . I have a List<SortableObjects> that is the
This question is kind of related to another question but I have a specific

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.