Reputation: 1260
I'm using VS2015 with the built-in IIS Express server...
Is it possible to enable Server Side Includes (SSI), eg this sort of thing:
<!--#include virtual="/include/test.shtml" -->
I know I can use SSI on full IIS but I can't find any info about using SSI on IIS Express.
(I can't use alternative methods of including snippets (eg asp) as this code also has to run on non-IIS servers.)
Upvotes: 1
Views: 2854
Reputation: 166
After a long and arduous search for a fix for this problem on several occasions over the last two years, I figured out the problem many of us were having. ASHRAF has the correct answer but I did not read carefully enough. His config file addition/change is for the .HTML file. I was adding it for the file BEING INCLUDED (*.inc) not the file doing the including (.html). Notice this line is for .html files Thanks ASHRAF.
Upvotes: 0
Reputation: 849
Have a look at: http://vlads-hideout.blogspot.com/2013/05/server-side-include-in-iis-express.html It is somewhat dated. The configuration file now can be found in the invisible ".vs" folder which is created by Visual Studio automatically inside your project folder. ".vs\config\applicationhost.config".
It already contains the globalModules entry:
<add name="ServerSideIncludeModule" image="%IIS_BIN%\iis_ssi.dll" />
and the following entries in /:
<add name="SSINC-stm" path="*.stm" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
<add name="SSINC-shtm" path="*.shtm" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
<add name="SSINC-shtml" path="*.shtml" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
So SSI is activated automatically for "*.SHTML", For example. If you do want to modify your default document or HTML files extensions, you can just put a clone of one of these configuration statements into the / section of your web.config and change the extension appropriately.
Upvotes: 0
Reputation: 3182
It has nothing to do with the file being .asp or not. You just need proper configuration.
I had the SSI module already installed and configured as part of IIS Express (I'm using Visual Studio 2017 Community Edition), although I found some articles suggesting that it needs to be installed separately.
In applicationHost.config file, there's this entry in the handlers
section:
<add name="SSINC-shtml" path="*.shtml" verb="GET,HEAD,POST" modules="ServerSideIncludeModule" resourceType="File" />
This means that your file needs to be of .shtml extension to be handled by the SSI module. Add an entry for yourself in your web.config file:
<configuration>
<system.webServer>
<handlers>
<add name="SSINC-html" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="File" />
</handlers>
</system.webServer>
Now SSI will work with ordinary HTML files.
Upvotes: 4
Reputation: 1260
It seems that the only way to get SSI to work is to rename my '.htm' and '.html' files to '.asp'. Then the SSI syntax works.
Which is a bit of a pain because I need to run the same code on non-IIS servers...
Upvotes: 0