I am mirgranting a classic ASP site to newer version of Windows server hosted in IIS 10.
When loading the default.asp page, I found in the browser's developer tool, network tab it says helpers.inc file could not be find. But it is in the same folder with the default page.
The helpers.inc file is invoked in the default.asp page by this code:
<script src="helpers.inc" language="VBScript" defer="true"></script>
If I try to access the helpers.inc file from browser, I will get this error:
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.
I tried add a handler mapping for *.inc file using the %windir%\system32\inetsrv\asp.dll executable, but it doesn't seem working. Gives me a new error:
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.
I am wondering what I need to let the include(.inc) file can be recognized/read by the asp page?
If this line is how it appears in the migrated code (without any modification)
<script src="helpers.inc" language="VBScript" defer="true"></script>
then one thing is clear.
This isn't a SSI (Server Side Include).
The tag defines a file with an .inc
extension as a Client Side VBScript. At the moment though, you haven't told IIS that .inc
is a file type it is allowed to serve as text/vbscript
.
Note: Having client-side VBScript defined in the page will severely limited cross browser compatability because VBScript is only supported in older versions of Internet Explorer.
404.3
?The reason for the 404.3
is because IIS blocks unknown file types. To fix this you need to add a MIME type mapping in IIS which I wouldn't usually recommend as .inc
is sometimes used as an extension for SSI files, but as we have debunked that theory mapping the MIME type is the way go.
There are only three ways to run server-side script in a Classic ASP page;
Using processor tags
<%
...
%>
Using script tags with the runat="server"
attribute.
<script language="VBScript" runat="server">
...
</script>
Adding an SSI using the #include
directive.
<!-- #include virtual = "somefile.asp" -->
Answer to IIS 7.5 doesn't run *.inc as ASP Classic (argument for not using .inc
extension for client-side script).
Answer to difference between mime types and extension filtering on IIS?.