Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

This is how to make a web server call your ISAPI dll using a custom file extension

79 views
Skip to first unread message

Mark Brittingham

unread,
Apr 13, 2000, 3:00:00 AM4/13/00
to
Hi folks,

I've had a request on how to create your own custom file extensions so
that, when the file is loaded, your ISAPI dll is automatically called
to handle the file. Here is that information - for more information
and more detail see the July issue of Delphi Informant.

------

How often have you seen a request on the newsgroup that goes something
like this: "I've written an ISAPI dll but it isn't handling my html
pages? How do I make this work?" Of course, the straightforward
answer is that you have to place a call to the DLL right in the page
request URL. That is, you'd use an URL like:

http://www.mysite.com/ISAPI/myisapi.dll/action1

Assuming you've placed your Delphi ISAPI dll in the directory pointed
to by the ISAPI virtual directory on your web server, this will cause
the server to load your dll and request that action1 be run. Action1,
of course, will typically load some HTML page from disk and process
all of the tags inside.

What you might not know is that there is an even easier way to get the
server to call your DLL automatically: custom file extensions. For
purposes of illustration, I'll use the custom extension "DWM" since
this is what I always use in my work. (DWM="Delphi Web Markup")

Enabling a custom extension requires a couple of minor changes in your
DLL and one or two tweaks to your web server.
First, the web server.

My favorite development server is the Omni web server from Omnicron
(http://www.omnicron.ab.ca/httpd/). It is small, fast and integrates
well with Delphi. To set up Omni, you add a new file type (extension)
to the "External" files listing area. That is, select "Properties |
Web Server Globals Settings" and click the "External" tab. To add
your new entry, place your extension (".dwm") in the "Virtual" field
and, in the "Actual" field, enter the path to your ISAPI DLL. Be sure
to press the Add button to register this addition! You also have to
make an entry in the "MIME" tab. Go there and enter "wwwserver/isapi"
in the "Virtual" field and ".dwm" in the "Actual" field and then *be
sure* to press the "Add" button.

In Microsoft's IIS the change is even simpler. First, get to the
Admin area by right clicking on the HTTP server and selecting
"Properties." Then press the "Configuration" button on the "Home
Directory" tab. Next, click the "Add" button and enter the path to
your DLL in the field labeled "Executable." Enter your extension
(".dwm") in the "Extension" field. To ensure that your DLL will
handle all page requests, select "All Verbs" and be sure to check the
"Script Engine" box. Back on out using the "Ok" buttons and you are
ready to go.

Your server will now call your ISAPI dll every time there is a request
for a file ending in .dwm!

In your DLL, the primary thing you will have to do is change your
thinking! For example, you *will not* use the HTMLDoc or HTMLFile
fields. Think about it - the server is going to TELL you which file
is being requested. Now, your task is to make sure that there is an
action waiting for a specific file request.

First, and the other change in your thinking, is that the root (or
default) action is suddenly a lot more important. The root action
will handle all of the pages that no other action handles explicitly.
In my MDWeb components (uploaded previously) I use the root action to
make sure all of the session information is tag-replaced in any DWM
file that doesn't have an explicit action set aside for it. Use your
imagination - get crazy! Just don't get *too* crazy and figure that
you'll just handle ALL dwm files by creating one massive root action
handler. Or, if you do, don't ever mention my name when describing
your solution...

Second, you *must* make sure that your actions have a PATH entry that
matches the path from your web root all the way down to the file that
is being requested. For example, if your ponytail (HTML guru) has
just created a page called "bigbucks.dwm" and has placed this file at
the root of your web site then the PATH in the corresponding action
will be "/bigbucks.dwm". Notice that the ".dwm" is included!! If the
file has been placed in a subdirectory of the root like:
"/obscure/moreobscure.dwm" then this is exactly the PATH you'll use in
your isapi action.
That's it. You now have the knowledge to create your very own "Web
Standard" file extension. Of course, if you do everything right and
your co-workers are awed by your technical breakthrough, pretend that
it really wasn't this trivial. Also, remember to talk in obscure and
reverent tones about stuff like "fundamental breakthroughs in web
technologies" and "server virtual application redirection." And, oh
yeah, you, my friend, *can* mention my name...

Mark Brittingham


Willi Krenn

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
...

> First, and the other change in your thinking, is that the root (or
> default) action is suddenly a lot more important. The root action
> will handle all of the pages that no other action handles explicitly.
> In my MDWeb components (uploaded previously) I use the root action to
> make sure all of the session information is tag-replaced in any DWM
> file that doesn't have an explicit action set aside for it. Use your
> imagination - get crazy! Just don't get *too* crazy and figure that
> you'll just handle ALL dwm files by creating one massive root action
> handler. Or, if you do, don't ever mention my name when describing
> your solution...

And if you want to achieve this in 5 minutes go to www.dwscript.com

Willi

Eric Pascual

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
>>
For example, if your ponytail (HTML guru) has just created a page ...file at
<<

Hey Mark, what's the problem with ponytails ?

I'm joking. I really appreciated your post. Gonna try your method (after
adapting it to Apache, if it's possible). And don't laugh at me because I'm
a ponytailed Delphian AND I'm using Apache as Web server :-)

Cheers
Eric

Mark Brittingham

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Actually, I take this from somewhere (internet.com?) where they refer
to HTML designers as "ponytails" and developers (ISAPI, ASP, etc.) as
"propheads"...

All in fun...

0 new messages