我将经典ASP网站迁移到IIS 10中托管的Windows Server的较新版本。
加载default.asp页时,我在浏览器的开发人员工具的“网络”选项卡中找到该文件,说找不到helpers.inc文件。但是它与默认页面位于同一文件夹中。
通过以下代码在default.asp页中调用helpers.inc文件:
<script src="helpers.inc" language="VBScript" defer="true"></script>
如果尝试从浏览器访问helpers.inc文件,则会收到此错误:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Most likely causes:
•It is possible that a handler mapping is missing. By default, the static file handler processes all content.
•The feature you are trying to use may not be installed.
•The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)
•If ASP.NET is not installed.
我尝试使用%windir%\ system32 \ inetsrv \ asp.dll可执行文件为* .inc文件添加处理程序映射,但是它似乎无法正常工作。给我一个新的错误:
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Most likely causes:
•The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.
我想知道我需要什么让asp页识别/读取include(.inc)文件?
如果此行是在已迁移代码中的显示方式(未经任何修改)
<script src="helpers.inc" language="VBScript" defer="true"></script>
那么一件事很清楚。
这不是SSI (服务器端包含)。
标记定义带有.inc
扩展名的文件作为客户端VBScript。不过,目前您还没有告诉IIS.inc
它是允许用作的文件类型text/vbscript
。
注意:在页面中定义客户端VBScript将严重限制跨浏览器的兼容性,因为VBScript仅在旧版本的Internet Explorer中受支持。
404.3
呢这样做的原因404.3
是因为IIS阻止了未知的文件类型。要解决此问题,您需要在IIS中添加一个MIME类型映射,我通常不建议这样做,因为.inc
有时将其用作SSI文件的扩展名,但正如我们所揭穿的那样,映射MIME类型的理论已成为现实。
在经典ASP页中只有三种方法来运行服务器端脚本;
使用处理器标签
<%
...
%>
在runat="server"
属性中使用脚本标签。
<script language="VBScript" runat="server">
...
</script>
使用#include
指令添加SSI 。
<!-- #include virtual = "somefile.asp" -->
IIS 7.5的答案不能作为ASP Classic运行* .inc (关于不对.inc
客户端脚本使用扩展名的说法)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句