I used to spend time parsing a URL string using old fashion .NET string methods. (Contains, Split, Substring, IndexOf, etc). I always thought, "There must be a better way to do this."
And there is, there is a tool in the .NET Framework to help you parse a fully qualified URI path.
System.UriBuilder
A few simple lines of code
Does a lot of the work for us.
And this is just one of the Uri tools. I encourage you to look at the others as well.
- System.Uri
- System.UriComponents
- System.UriFormat
- System.UriHostNameType
- System.UriIdnScope
- System.UriKind
- System.UriParser
- System.UriPartial
- System.UriTypeConverter
So does this mean I need to re-write my HTML utility?
ReplyDeleteAs always a genius, and not only in your own mind!
ReplyDeleteAdd HttpUtility.ParseQueryString(uri.Query) to the mix and you've got everything you need.
ReplyDelete@rouftop Now why didn't I think of that? Awesome suggestion!
ReplyDelete