public static Uri GetRelativeUri(Uri sourcePartUri, Uri targetPartUri) { Check.SourcePartUri(sourcePartUri); Check.TargetPartUri(targetPartUri); Uri uri = new Uri("http://fake.com"); Uri a = new Uri(uri, sourcePartUri.OriginalString); Uri b = new Uri(uri, targetPartUri.OriginalString); return(a.MakeRelativeUri(b)); }