经典ASP页面include(.inc)文件的IIS处理程序映射

Xiao Han

我将经典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)文件?

Lankymart

如果此行是在已迁移代码中的显示方式(未经任何修改)

<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类型的理论已成为现实。


为什么不是SSI

在经典ASP页中只有三种方法来运行服务器端脚本;

  1. 使用处理器标签

    <%
        ...
    %>
    
  2. runat="server"属性中使用脚本标签

    <script language="VBScript" runat="server">
        ...
    </script>
    
  3. 使用#include指令添加SSI

    <!-- #include virtual = "somefile.asp" -->
    

有用的链接

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将包含经典ASP页面以及ASPX页面的ASP.NET应用程序从1.1框架迁移到4.0

如何在经典的 asp 页面上从 webconfig 文件中获取邮件设置

为什么在为ASP经典页面IIS6调试vb 6 dll时我的ObjectContext为空?

在经典的ASP中上传文件

ASP.NET Core映射到静态文件处理程序的路由

经典ASP下载页面加载PDF

如何使用页面错误处理程序映射页面?

经典的ASP / ASP.NET应用程序变量

经典ASP,IIS 8.5,CINT CLNG无法正常工作

通过经典ASP在IIS中创建虚拟目录

经典ASP文件属于哪个文件夹

经典的 ASP 应用程序默认启动 Firefox 吗?

使用经典的 ASP/VB 脚本读取 CSV 文件

在经典ASP中为文件夹设置的重定向

如何在经典 ASP 上设置默认内容页面?

如何在经典的ASP页面中编写VB代码

iOS WebView 显示返回经典 ASP 页面日期时间不同

我如何在MVC项目中包含经典的ASP页面

使用COM对象的经典ASP页面非常慢

通过运行asp.net mvc Web应用程序的IIS访问映射的驱动器

将经典 ASP 应用程序迁移到 ASP.NET Core

经典ASP / IIS6 / Win2003 Server无法与TLS服务器通信

IIS 7 SQL Server会话管理:在哪里可以找到ASP经典的COM对象dll

从经典的 asp.net 应用程序打开 mvc 应用程序

ASP.Net将自定义HTTP处理程序移动到IIS 8.5

在经典的 asp.net 表单应用程序中使用 websockets

经典的ASP应用程序是我们环境的安全漏洞吗?

Visual Studio 2015中的经典asp“已禁用应用程序调试”

经典ASP使用OraOleadb驱动程序调用Oracle存储过程