Search code examples
c#asp.netlocationhttpresponseuniversal

What exactly does Response.Redirect("~/...") put in the HTTP response?


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?


Solution

  • 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.