MFC ISAPI Template and ISAPI Development


I’ve read on msdn that for Visual Studio 2005 the MFC ISAPI extension template was discontinued and that for new development “ISAPI entry point functions” should be used instead.

I’m interpreting that as the MFC isapi classes are problematic. Could you give some honest commentary regarding the issues?

I’ve looked at my mfc isapi that I would like to update and can eliminate the dependency on mfc with own C++ classes.

From a practical standpoint, I was wondering if 2005 Standard Edition would do me any good since MFC is included, but since it isn’t being encouraged I thought I would just continue my project using Express and really get to know ISAPI (which has been fun so far and not as hard as I thought).


I presume you are referencing the following documents:

Actually, I do not interpret the removal of MFC ISAPI Template as an indication of it being problematic. Instead, I will phrase its removal as closer to:

  • “Low popularity” relative to other project types (i.e. is it really as popular as a CLR Console Application or Windows Forms Application?)
  • ISAPI is not intrinsically .NET-anything
  • ATL Server actually provides a usable framework on top of ISAPI that connects with .NET, while MFC ISAPI Template offers little

In other words, from a .NET perspective, pure ISAPI development is out-of-date, so the costs of maintaining such a template project does not make sense. Plus, ATL Server has a future while MFC ISAPI Template never offered much… so the choice is pretty clear.

Frankly, I have no problems with the removal of MFC ISAPI Template. If I could roll back time, I actually wish that the Visual C++ team never introduced the MFC ISAPI Template because it simply introduces ISAPI developers to an abstraction and dependency layer on top of ISAPI which offers no benefits to the developer. How so?

The Template attempts to snap a MFC Windows Application-like feel on top of ISAPI, which is a fundamentally incompatible paradigm that never made sense. And it does not help with the tricky parts of HTTP and ISAPI that developers actually need help with.

Why NOT MFC ISAPI Template

For example, the global CMyApp object makes no sense for ISAPI because HTTP is intrinsically stateless – so it is more important to keep per-request state and global “Server functions”. But, CMyApp does not provide those useful things that developers want, like configurable per-request state (i.e. custom session state implementation) nor any global “Server functions” (i.e. customizable response caching implementation)… so it really fails to make the ISAPI developer’s life easier.

Another example is the PARSE_MAP. It is a wonder abstraction for Windows Applications, but in the HTTP world, all it does is force a certain proprietary querystring parse pattern, and PARSE_MAP is not so good at malformed querystrings nor malformed PARSE_MAPs, either. It is infinitely more useful for PARSE_MAP to provide the standard parse/decoding for HTML Form variables because that is a more likely source of input values – an ISAPI handing a FORM POST or FORM GET – and the ISAPI needs an easy way to parse/retrieve form variables by name and act on them. Once again, opportunity missed.

Then, there is the debacle with its wrapping of ISAPI Filter HTTP_FILTER_CONTEXT or ISAPI Extension EXTENSION_CONTROL_BLACK. Instead of introducing a secure paradigm of request handling and helping developers correctly use ISAPI function calls like GetServerVariable(), WriteClient(), or GetHeader(), it basically thinly wraps those API calls and leaves the developers to fend for themselves. This provides absolutely no value-add to the developer; you are just as likely to misuse the ISAPI function call with or without the framework; so where is the value-add for taking a dependency?

My Take…

MFC makes sense for Windows Application because it introduces a compatible paradigm which removes much of the boiler-plate code you otherwise have to write for Win32. This is not what MFC ISAPI Template offers.

So… I would never recommend anyone use the MFC ISAPI Template. It is useless from my perspective – offers no benefits and adds a complexity and dependency layer into my ISAPI. I always write my ISAPIs as a plain Win32 DLL which exports the required ISAPI function signatures for IIS to load and use. Lean and to the point.

Now, I do not recommend rolling your own C++ classes to handle a lot of the basic ISAPI chores… that’s the stuff that a real framework/template SHOULD provide you. So, what ISAPI framework do I recommend people to use? For an example of a good lightweight ISAPI Framework, check out ISAPITools.h from the latest IIS Platform SDK.

Wade wrote it to make ISAPI easier to use, providing useful abstractions like an efficient and resizable buffer, functions for logical ISAPI tasks like retrieving server variables, reading entity body, decoding common HTTP encodings, avoiding all the classic ISAPI mistakes, and generally illustrating the Right Way (TM) to do things in ISAPI.


In other words, the MFC ISAPI Template is not a deciding factior between Visual C++ 2005 Express or Standard. I am actually pretty happy with Visual C++ 6.0 for ISAPI development; Visual C++ 2005 Express does the job as well, but it does not improve the ISAPI development experience. I use it because Visual Studio Express Editions are powerful, functional, and free.

MFC ISAPI Template looks like someone’s attempt to make writing an ISAPI like writing an MFC Windows Application for the Web… without understanding how the Web works.

Now, we are planning to fix this for IIS7 where the IIS team (not Visual C++ team) is going to come up with the Application Wizards, Framework, and Templates for native and managed modules extending IIS7 behavior. And we’ll get an UI designer to make it look nice, too. 🙂 In fact, I am authoring some of those pieces right now…


Comments (11)

  1. PrzemekW says:

    Well, good alternative is ATL Server ISAPI Extension classes … They offer quite nice object model and I found them to be more robust than those classes that come with IIS SDK

  2. David.Wang says:

    PrzemekW – yeah, ATL Server provides a real substantive model which actually tries to layer away the raw ISAPI interactions with more higher-order functionality. It does not make ISAPI easier to use; it makes building higher-order applications on top of ISAPI easier.

    On the other hand, the ISAPITools classes that come with IIS SDK are targetted at making raw HTTP/ISAPI interactions more friendly. It doesn’t try to provide a model; it just makes ISAPI easier to use.

    They target different needs and both have their place. The MFC Templates, on the other hand, add no real value.


  3. David Wang says:

    IIS has always had an identity crisis. Is it a platform for hosting and building web applications, or…

  4. Mario Bonito says:

    Hi David,

     Small question. I have been trying to develop some ISAPI extensions and filters. It has been difficult cause it is vague wether ISAPI for IIS6 and up should be in C or C++. Also I would like to chain some extensions together, yet seem to be at a loss on how to exactly do that. Do you have some resources ( web / books ) you would reccomend to help a fellow developer get off the ground with ISAPI.

    Thank you in advance.


  5. David.Wang says:

    Mario – there is no language requirement for ISAPI – anything that can create a Win32 DLL with the necessary exports will work.

    I do not know what you mean by "chain some extensions together" – are you saying that you have the binary DLL of several ISAPI DLLs which you’d like to compose into a single action?

    If so, you cannot chain ISAPI Extensions unless the ISAPI itself is written to support chaining. ISAPI Extensions are supposed to handle and terminate request processing.


  6. mario says:

    Wow, awesome did not know that about ISAPI. All examples in the SDK were C based. So VB.Net or C# could be used? I am a little confused about the exporting you mentioned.what do you mean when you say exports?

    Ok, I see about the ISAPI chaining. Basically I was hoping to save some time and build a Parent ISAPI that would call other dll’s ( ssiinc.dll is an example ) then receive the processed request back from this dll and then process before handing back to the client.


    Thank for you prompt and informative response.


  7. David.Wang says:

    mario – Managed code do not have syntax to export signatures on managed assemblies, so they cannot be used. Conceptually, it is like adding "public" access modifier on a method in managed code, but the two technologies are different and incompatible.

    Even with chaining, you cannot achieve what you want because it requires buffering of output (so that the chained ISAPI can see the response of the processed request to perform additional processing).


  8. Mario says:

    Thank you David,

    Makes sense, was hoping that Microsoft would have some tricks, but I guess the standards are the way to go. Looks like I am back to either Delphi or C/C++ to get the filter built. As per my first comment. Any good resources ( C/C++ Books, and ISAPI Development Books ) you can reccmend to help in the development of ISAPI Filters.



  9. David.Wang says:

    Mario – sorry, I do not know of any good books on ISAPI.

    I suspect you should be able to find all the useful information you need between my blog and the public Microsoft ISAPI-DEV newsgroup – microsoft.­public.­platformsdk.­internet.­server.­isapi-dev


  10. JAG says:

    How to run  dll ( developed  using  ISAPI Program) in a webbrowser using IIS.

  11. David.Wang says:

    JAG – it is not possible to run a dll (developed using ISAPI Program) in a web browser using IIS.

    It is possible to run an ISAPI DLL on the IIS web server to generate a HTTP response for a web browser to display.

    How to set this up is standard. Please look up documentation on for assistance.