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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:22:29+00:00 2026-05-13T14:22:29+00:00

The following line of code gives an exception. Is this a bug in the

  • 0

The following line of code gives an exception. Is this a bug in the framework? If not what approach could I take instead?

It seems to be the “:” (colon) that causes in the issue, however I do see such a URI working on production websites ok (i.e. seems to be a valid URI in the real world)

Uri relativeUri = new Uri("http://test.com/asdf").MakeRelativeUri(new Uri("http://test.com/xx:yy"));
// gives => System.UriFormatException: A relative URI cannot be created because the 
// 'uriString' parameter represents an absolute URI

Uri relativeUri = new Uri("http://test.com/asdf").MakeRelativeUri(new Uri("http://test.com/xxyy"));
// this works - removed the colon between the xx and yy

PS. Specifically can I ask given the above is the case, what .NET class/method could I use (noting I am parsing a HTML page from the web) to take (a) the page URI and (b) the relative string from a HTML HREF argument [e.g. would have been “/xx:yy” in this case] and return the valid URI that could be used to address that resource?

In other words how do I mimic the behavior of a browser that translates the HREF and the page URI to produce the URI it uses to go to that resource when you click on it.

  • 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-13T14:22:29+00:00Added an answer on May 13, 2026 at 2:22 pm

    I consider it a bug.

    RFC1738 says that : (amongst other characters) may be reserved for special meaning within a scheme. However the http scheme does not reserve it in the path part

    Within the <path> and <searchpart> components, "/", ";", "?" are reserved.
    

    (Not :.)

    hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
    

    So, http://test.com/xx:yy is a valid URI. The newer RFC3968 agrees:

    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
    

    However of course, relativised against http://test.com/asdf, the resultant xx:yy would be an absolute URI and not a valid relative URI:

    path-noscheme = segment-nz-nc *( "/" segment )
    segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
                    ; non-zero-length segment without any colon ":"
    

    So MakeRelativeUri is kind of right to report there’s a problem, but really it should be fixing it automatically by encoding the : that is valid in an absolute URI to a %3A that is valid in the first segment of a relative URI.

    I would generally try to avoid MakeRelativeUri in favour of root-relative URIs, which are easier to extract and don’t have this problem (/xx:yy is OK).

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

Sidebar

Related Questions

Executing the below code gives me the following exception on the last line: InvalidOperationException:
The following line of code is causing me an Exception using (new INVU.API.CallContextStore()) {
The following code gives me a really weird error in Firefox: Error: uncaught exception:
I have following line code in my view: <td> Model.some_instance_method(args) </td> I would like
The following line of code causes a JScript object expected error in IE: hideElements.apply(window,
The following line of code <% invite.accepted ? { @going, @not_going = 'selected', ''
The following line of code generates the compile time error (PE19) There is no
The following line of code causes my program to break in a very strange
I have the following line of code in javascript: (Math.random() + ) * 1000000000000000000
I have the following line of code: group p by new DateTime((p.DateTime.Value.Ticks / interval.Ticks)

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.