Parse relative URI

Although you can create a Uri without a host portion, most of its properties will then throw an InvalidOperationException (“This operation is not supported for a relative URI”) because those properties rely on an absolute Uri.

HttpUtility.ParseQueryString() is indeed not going to help here, because it only operates on the query part of an Uri, which you cannot obtain because you don’t have an absolute Uri.

So although it might seem hacky, I think the new Uri(baseUri, relativeUri) contstructor does exactly what you want. I cannot seem to find a better or cleaner way to accomplish the same.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)