Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect new Uri(base, relative) behaviour in .NET

When you create a new Uri like this:

New Uri(New Uri("http://example.com/test.php"),"?x=y")

it returns:

http://example.com/?x=y

It was supposed to return:

http://example.com/test.php?x=y

according to the every major browser out there (I'm not quite sure what RFC says though).

Is this is a bug or is there any other function out there which behaves correctly, also what's the best way to fix it without reinventing the wheel?

like image 910
dr. evil Avatar asked Jan 08 '10 13:01

dr. evil


1 Answers

Yes, it looks like a bug to me. In particular, I would suggest that when you report this on Connect you refer to RFC 1808, in particular section 4 step 5, and section 5.1 with this example:

Base: http://a/b/c/d;p?q#f
Relative: ?y
Absolute: http://a/b/c/d;p?y

Not sure about the best way to fix it, I'm afraid :(

like image 127
Jon Skeet Avatar answered Oct 23 '22 03:10

Jon Skeet