Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebMatrix parse .html file as .asp

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?

like image 977
Brian Fisher Avatar asked Dec 21 '22 14:12

Brian Fisher


2 Answers

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.

like image 89
Mike Brind Avatar answered Dec 26 '22 08:12

Mike Brind


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>
like image 43
kkhimself Avatar answered Dec 26 '22 08:12

kkhimself