Jim Grant
Jim Grant

Reputation: 1148

Problems with including files for ASP in IIS 7.5

thanks for taking the time to read this question of mine, which I'm sure is a school boy error but for the life of me, cannot see it.

I have an ASP page which has the following contents:

<!-- #include file="include.asp" -->
<%
Dim ConfigFile
ConfigFile = Left(Request.ServerVariables("URL"), InStr(Request.ServerVariables("URL"),"/framework/lib/dms/asp/"))
ConfigFile = ConfigFile & "project/config/ConfigDms.inc.asp"

%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ConfigFile%>
</BODY>
</HTML>

Which works when accessed as a stand-alone page, or when called via an iFrame (don't ask). However, if I add the line "include ConfigFile" the page returns a 404 error in IIS. The value of ConfigFile is "/cms/project/config/ConfigDms.inc.asp", as printed out in the body of the page.

If I add the line "include https://xxx.xxx.xxx.xxx/cms/project/config/ConfigDms.inc.asp" to replace the original include statement, it works as intended.

Now I'm sure that this is a configuration error, but either though I put the ASP setting "enableParentPaths" to true and scrip "errorsenttobrowser" to true, I'm still not getting anywhere.

I have identical code on another server running an older version of IIS and it is working fine, however, I never setup the original server and have no documentation for setting up the new server.

The ASP script which causes the 404 error looks like:

<!-- #include file="include.asp" -->
<%
Dim ConfigFile
ConfigFile = Left(Request.ServerVariables("URL"), InStr(Request.ServerVariables("URL"),"/framework/lib/dms/asp/"))
ConfigFile = ConfigFile & "project/config/ConfigDms.inc.asp"

include ConfigFile
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ConfigFile%>
</BODY>
</HTML>

But this file works fine:

<!-- #include file="include.asp" -->
<%
Dim ConfigFile
ConfigFile = Left(Request.ServerVariables("URL"), InStr(Request.ServerVariables("URL"),"/framework/lib/dms/asp/"))
ConfigFile = ConfigFile & "project/config/ConfigDms.inc.asp"

include "https://xxx.xxx.xxx.xxx/cms/project/config/ConfigDms.inc.asp"
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ConfigFile%>
</BODY>
</HTML>

Regards

Upvotes: 0

Views: 337

Answers (1)

Jim Grant
Jim Grant

Reputation: 1148

The reasoning for getting 404 errors when trying to access a particular page, was indeed correct. A colleague of mine changed the default error messages for bespoke ones, but failed to copy the actual HTML error pages onto the server.

This meant a 500 error was detected, tried to display the 500.html page but couldn't find it and hence displayed a 404 error.....

Sorry for anyone who has spent time reading this...

Upvotes: 1

Related Questions