IIS Server Side Includes doesn't process ColdFusion
How can I use the Server Side Includes module in IIS to include and process a ColdFusion file from a .htm file? I'm currently doing something like this in my html file:
<!--#include virtual="navmenu.cfm"-->
This includes the raw contents of the navmenu file. I need it to execute the ColdFusion code and return the output of that pro开发者_JS百科cess rather than including the raw ColdFusion code.
This same syntax works properly in Apache.
Are you just trying to avoid the CFM extension in the URL?
You can't use SSI to include a CFM files into a static HTM file. You can configure IIS to send HTM files to the CF server to be parsed. This would allow you to use CFINCLUDE inside any HTM file.
Alternately, you can use ajax from your HTM file and load the parsed CFM content into a DIV.
If you can't make the top page appear to be a cfm to the outside have you thought about using the URL Rewrite Module for IIS? That way you could just make certain files cfms with some explicit htm to cfm rewrite rules but leave all others unprocessed. Beyond that I think there may not be an elegant answer since you are mixing static and dynamic content.
On your comment about ajax - personally I don't find anything tedious about using ajax but then again jquery spoils you...
<div id='menuhere'></div>
$.get('navmenu.cfm', function(data) {$('.menuhere').html(data); });
Accomplishes the same thing as the SSI plus (assuming jQuery is cached) you get faster main content page loads to boot.
If you are using a Coldfusion page it is:
<cfinclude template="navmenu.cfm">
If you are using another type of page you will need to put that content in an IFRAME
<iframe src="navmenu.cfm"></iframe>
The question is if you have Coldfusion technology available on the server, why not change that page to a .cfm page and use the above example?
精彩评论