I need to combine two url's that both contain .Path info.
I would like to use Uri to give me possibility to .TryCreate() so i can catch malformed url's.
The problem that im 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 info using Uri class?