303 redirection strategy for IIS

In message <4A532D33.2070401@openlinksw.com>, Kingsley Idehen 
<kidehen@openlinksw.com> writes
>>> PS: any IIS user volunteering to translate those recipies to IIS 
>>>configuration?
>>
>> I have implemented the 303 redirection strategy in IIS, but using a 
>>custom 404 "page not found" error handler.  Is that relevant to this 
>>discussion?
>>
>> Richard
>Absolutely!

OK, here goes:

Attached is an IIS Active Server Page which handles 404 "page not found" 
errors.  The logic is that since the abstract URLs/PSIs representing a 
concept/subject do not have a corresponding page, they will end up here.

The 404 handler contains rules which pattern-match on the requested URL 
and Accept header, and specify an action and a mapped URL for each. 
These rules deal with both the initial 303 redirection of the incoming 
request, and the delivery of the actual RDF resource when the client 
subsequently requests the re-directed URL (which is also a mythical 
page!).

1. Rule for simple re-direction
ReDirect_Add "/object/*", "/object/rdf/*", "SEEALSO", 
"application/rdf+xml", sRules

SEEALSO implements a "303 See Other" redirect, substituting the second 
pattern for the first in the URL when the Accept header specifies 
"application/rdf+xml".

2. Rule for direct delivery of RDF content
ReDirect_Add "/object/rdf/*", 
"rdf?class=object&target=4&level=3&application=Object&filename=WTcoll&ind
exname=Identity number&indexkey=*", "EXECUTE", "", sRules

EXECUTE actually delivers the requested content.  It does this by 
substituting the URL for the second pattern, then actually fetching that 
content (which is an XML resource), converting it on the fly to RDF 
using an XSLT transform, and returning it as the response to the 
(second) HTTP request.

Initially I thought I could do all of this by redirection, so that a 
request for the "/object/rdf/*" pattern would simply be handed off yet 
again by a second redirect.  However, I found that (for me, at least) 
this didn't work.  Hence the need for "grunt" code within the 404 
handler, actually delivering RDF content.  Anyone wanting to use this 
ASP handler would, of course, have to modify the code which generates 
the RDF: this is the routine GetRDF.  (If you're using the same strategy 
as me, i.e. on-the-fly conversion of XML, then this may just be a case 
of changing the base URL from which the XML comes, and the name of the 
XSLT transform.)

Having put all of this in place, it was easy for me to add code to 
deliver a Topic Map representation of the same resource, simply adding 
another pair of rules.  You could use the same approach to deliver N3, 
etc.

Richard
-- 
Richard Light

Received on Thursday, 9 July 2009 10:29:03 UTC