I need to combine two URL's that both contain .Path information.
I would like to use Uri
to give me possibility to .TryCreate(), so I can catch malformed URL's.
The problem that I'm facing is that the base URI path seems to be ignored when I merge the absolute and the relative URI:
Uri absoluteUri= new Uri("http://hostname/path/", UriKind.Absolute);
Uri relativeUri = new Uri("/my subsite/my page.aspx?my=query", UriKind.Relative);
Uri resultUri;
if (!Uri.TryCreate(absoluteUri, relativeUri, out resultUri))
// handle errors
Output of the above is:
http://hostname/my%20subsite/my%20page.aspx?my=query
I would like it to be:
http://hostname/path/my%20subsite/my%20page.aspx?my=query
Is there a way to combine URLs that both contain path information using the Uri
class?