"1" and "2" are the "file name part" of the URL. If you make "1" more like a directory path, it will work fine "1 /":
var baseUri = new Uri("http://localhost/"); var uri1 = new Uri(baseUri, "1/"); var uri2 = new Uri(uri1, "2");
Note: "part of the file name" is not a real term, since Url has only "path" and "request", but usually the last piece of the path is considered as the file name: "/ foo / bar / file. Text".
When you combine 2 paths, you want to replace part of the tail of the first path with the second. In your case, it ends up with only the “file name” segment for both: “/ 1” and “2” (if you put a real value like “/myFile.txt” and “NewFile.txt” when merging, it would be easier to understand why it behaves in this way).
source share