Art Of Programming

musings by Dmytrii Nagirniak

Embarrassment With .NET URI

I need to work with the URI in .NET. What I need to do is:
  • Parse URI from a poor string to be able to extracts its parts
    • name/value pairs of a query;
    • scheme
    • host
    • path
  • Generate URI based on
    • name/value pairs of a query;
    • scheme
    • host
    • scheme + host parts
    • path
  • Modify URI the same way
    • name/value pairs of a query;
    • scheme
    • host
    • scheme + host parts
    • path
There are basically 2 types in .NET that can help with it: Uri and UriBuilder. Neither of them allows me to do all the things I mentioned properly.
Uri class does not give name/value pairs. So I have set of extensions to do that. Not a big deal, but it is not there, in .NET.
UriBuilder has a ridiculous bug; and guess what. The status is Closed as by Design. WTF! Just insane!
What a shame on .NET. How long should I concatenate the strings and use my own utils when things are a bit more complicated that just absolutely simple? Sick and tired of that.
I definitely need to get my hands on some RFC and implement it properly.

Comments

Anonymous
Have to agree that .NET's Uri class is dreadful, especially when it comes to handling query strings.

Comments