3

I've just finished reading URL vs. URI vs. URN, in More Concise Terms, and it's really helped understand the distinction between the three terms. Since then I've skimmed the RFC2141 and RFC2616 specs and Microsoft's Response.Redirect Method documentation in an effort to answer the following question confidently.

Given this line of code:

Response.Redirect("~/Foo.aspx");

And this resulting HTTP response (trimmed for context):

Status=Found - 302 Date=Wed, 24 Nov
2010 17:27:58 GMT
Server=Microsoft-IIS/6.0
X-Powered-By=ASP.NET
X-AspNet-Version=2.0.50727
Location=/MyWebApp/Foo.aspx

What name(s) most properly describes what has been placed into the "Location" header?

URL? URI? URN? URC? Which is it?

lance
  • 16,092
  • 19
  • 77
  • 136

5 Answers5

2

It's a relative URI.

It's also a URL since it can be used in this context to locate the resource as well as identifying it, but really there's little value in talking about URLs these days - the distinction is more a matter of what you're doing with it than what it is in itself, and a URL is always a URI.

Jon Hanna
  • 110,372
  • 10
  • 146
  • 251
  • But doesn't the location address fail the URL test of being derefrence-able? /MyWebApp/Foo.aspx provides no information about where the resource can be found on a network... – Evan Nov 24 '10 at 17:53
  • 1
    It's a relative reference. That along with other information (the URI used to get the response) allows the creation of an absolute URI that is both a global identifier (no other resource in the world has the same URI) and dereferencable. – Jon Hanna Nov 24 '10 at 17:59
  • @John Doesn't that make the location not a URL but a URN? – Evan Nov 24 '10 at 20:45
  • @Evan How? I don't follow your argument. – Jon Hanna Nov 25 '10 at 12:32
  • @John "That along with other information." The value "/MyWebApp/Foo.aspx" must be combined with other information to create a global identifier - a URL - therefore, the value "/MyWebApp/Foo.aspx" qualifies only as a URN but not a URL. – Evan Dec 01 '10 at 20:18
  • @Evan, No, it doesn't count as a URN because a URN suffices to act as a global identifier (hence making all URNs URIs). A relative URL is a relative URI - a reference that in the context of another URL can create a full URL (which again is also a URI). Relative URIs are a way to encode a full URI in the context of another full URI which can remain meaningful (but different) when transferred to another context. – Jon Hanna Dec 02 '10 at 10:08
  • @Evan, urn:isbn:1904808433 in contrast is a URN (and also a URI). It gives a global identifier that always identifies the same book (forgive some self-promotion in the choice of which! hey, if I have to pick one...), but encodes no information about how to obtain further information about that book. http://www.hackcraft.net/bookref/?urn:isbn:1904808433 is something I might use to direct people to the relevant amazon page, but someone else can do something completely different with the same URN. We'd both be dealing with the same book, but with different information location methods (if any). – Jon Hanna Dec 02 '10 at 10:11
1

It's a tricky question. On its own (as a string) Location is a URI, but you have to take into account the context in which it is defined (that being the response header list) In essence a tuple (browser::request::protocol, browser::request::domain, response::locationHeader) constitutes a URL as request adds a retrieval mechanism.

mmix
  • 6,057
  • 3
  • 39
  • 65
0

It is an Url since the resolution of ~/ provides both the location and the mechanism ("http") to find the resource, however, the header value Location is designed to take an Uri.

Header Field Definitions

Thomas
  • 63,911
  • 12
  • 95
  • 141
  • 1
    But, I'm asking what to name the value that's *in* the header, without concern about how/where that value was created. The value that's in the header doesn't provide the location, or the mechanism. If the location and mechanism are things I want to observe in something I call a "URL", and those things aren't in the "Location" header, what do we call the value that appears *in the header*? – lance Nov 24 '10 at 17:46
  • @lance - Amended my response. It is an Uri. – Thomas Nov 24 '10 at 17:50
0

~/ is resolved to /MyWebApp/Foo.aspx, which doesn't declare the mechanism involved being HTTP; all it declares is the location that is being redirected to - which makes it a URL, though it's not explicitly stating http:// in there.

Arantor
  • 597
  • 4
  • 15
0

The URL in the Location header property is a root-relative URL. The ~/ specifies that the URL being created with ~/foo.aspx should be root-relative to the application directory in IIS.

DarrellNorton
  • 3,901
  • 2
  • 21
  • 21