Is there any reason to use System.Uri?

.net

Solution

I wouldn't say the Uri class is fundamentally broken at all. The purpose of the Uri class is to provide a compact and standard representation of a URI. The Uri class encapsulates all of the logic needed to return the URI in a canonical form and to provide support for IPV4 and IPV6 notations, and IRI support.

The Uri class is not designed to allow changing the Uri once it has been created; if you want that level of mutability you should use a UriBuilder instead.

The benefit to using Uri (or UriBuilder) over strings is that you get a lot of validation built in to ensure that the given address is well-formed, capabilities to make relative URIs from absolute ones, etc. Essentially, you can think of a Uri as an actual data type, so using one provides a level of strong typing.

Problem

I'm looking it over and it seems to be that it is fundamentally broken. - Only 5 instance methods aren't marked obsolete. - There doesn't appear to be any built-in way to parse query-string variables. - There are no methods to mutate the Uri, for example appending a new query variable. - HttpUtility works on strings, not URIs So is there anything it is good for? Should I really be using this instead of just strings?

Original source