URIs, URLs, and strings
I've been wondering why several methods in the .Net framework accept a
string parameter for a URL. Furthermore, there's that whole URL vs. URI issue.
Here's an article I liked on the URI vs. URL issue:
http://www.bernzilla.com/item.php?id=100
In looking at the .Net framework classes
Uri and
Url, it seems they intend the
Url class to be something special to use in verifying security policy on assemblies. It's part of the
System.Security.Policy namespace. Furthermore, it messes with security permissions, which is a whole topic unto itself in .Net. I decided it makes more sense to use the
Uri class for what I'm doing, even though I'm specifically working with a URL in this siutation. I just didn't like the fact that the
Url class is tied into
System.Security.Policy.
I'm designing some framework classes and want to be careful about the APIs. So, I was wondering why did Microsoft choose a string instead of using the
Uri class in various places in the Framework. While I don't know the answer to that question, I found a great blog from Brad Abrams (lead program manager for the .Net framework). It's a design guideline for using a Uri vs. string.
Here's the blog:
http://weblogs.asp.net/brada/archive/2004/01/12/58031.aspx
Maybe this guideline means we'll see some overloaded methods in the future that accept both a
string and a
Uri. Meanwhile, I'm going ahead and using the
Uri class instead of a
string parameter.