4

I have a file with .html extension that contain the:

<!--#include virtual="filename"-->

directive and I'm using Microsoft WebMatrix. When I run the web pages from WebMatrix the directive isn't processed and instead the directive shows up in the HTML. How can I configure WebMatrix to treat these pages as if they were .asp files?

Brian Fisher
  • 23,519
  • 15
  • 78
  • 82

2 Answers2

7

You need to configure the web server to map .html files to asp.dll. If you want to do this locally with IIS Express, you can add a new entry to the applicationhost.config file under the <handlers> section like this:

    <add name="ASPClassicHtml" path="*.html" verb="GET,HEAD,POST" 
         modules="IsapiModule" scriptProcessor="%IIS_BIN%\asp.dll" 
         resourceType="File" />

That's basically a copy of the existing entry for ASPClassic, but pointing to html files. You can usually find applicationhost.config in My Documents > IISExpress > config.

Mike Brind
  • 28,238
  • 6
  • 56
  • 88
  • I added that line to the applicationhost.config, but it still just renders the file with the directives in it. Thanks. – Brian Fisher Apr 27 '11 at 04:29
  • Did you stop the site and then restart it? You probably needed to clear your browser cache as well. – Mike Brind Apr 27 '11 at 05:35
  • 1
    I think this new handler should be placed before 'StaticFile' handler in the handlers list. – vikomall Apr 27 '11 at 05:35
  • I placed it immediately below the existing ASPClassic entry. WOMM. I did need to clear the browser cache, though. – Mike Brind Apr 27 '11 at 05:41
  • I had placed it at the bottom of the handlers section. When I moved it above the StaticFile entry it worked. Thanks! – Brian Fisher Apr 27 '11 at 18:54
  • I found this worked perfectly fine in webServer/handlers section of Web.config. I then added a transform in the Web.Release.config since `asp.dll` is located elsewhere for IIS: `` – Jonathon Watney May 28 '19 at 17:56
4

To enable Server Side Includes without passing all HTML files through the ASP processor, you can add these two "add" elements to the handlers section. Make sure you add it to the beginning of the section.

<handlers accessPolicy="Read, Script">
    <add name="SSINC-htm" path="*.htm" verb="GET,POST" modules="ServerSideIncludeModule" resourceType="File" />
    <add name="SSINC-html" path="*.html" verb="GET,POST" modules="ServerSideIncludeModule" resourceType="File" />
    ...
    ...
    ...
</handlers>
kkhimself
  • 71
  • 4