Search code examples
syntaxasp-classiclanguage-design

Why is the classic ASP server-side include enclosed in a comment?


Why is the syntax for server-side inclusion <!--#include file="suchandsuch"-->?

Placing semantically meaningful content inside a comment seems awkward and misleading – indeed, the first time I saw this syntax, I assumed it was an include that had been "commented out". What was the reasoning behind designing the language to use this syntax, as opposed to alternatives like <% #include file="suchandsuch" %>?

(I'm aware that parsing that example alternative with simple substitution would render something like <% <% vbscript_stuff %> html_stuff %>, but it should be trivial to parse it a little more intelligently to avoid misusing HTML comments.)


Solution

  • I think the main reason is the server side processing in the case of server side includes is handled directly by IIS then passed off to the processing engine the content is related to.

    So using the example in the question, if the syntax was;

    <% #include file="suchandsuch" %>
    

    then it's dealing direct with ASP processing syntax which means the SSI definition is no longer generic in it's approach.

    As stated in the MSDN Library documentation

    This directive can be used in an ASP page, STM page, INC page, or any page with a file name extension that is mapped to the SSI interpreter (Ssinc.dll) or to the ASP interpreter (Asp.dll). If you have IIS Manager installed, you can modify default application mappings and add new mappings.

    Also as the <!-- --> comment is processed server side it never reaches the client's browser so HTML semantics are unaffected.


    Useful Links