3

I'm trying to understand ASP but #include doesn't seem to work for some reason. I'm using IIS 7.5 (included with Win 7).

I have two .asp files in .../wwwroot/MyWeb/. I'm trying to #include FiboRecursive.asp in a file called test.asp. Both files work separately if I remove the #include. I have tried both virtual and file includes.

This is test.asp:

<%@ language="javascript" %>
<html>
<body>
<p>
<% //Response.Write(Request.ServerVariables("http_user_agent"));%>
</p>
<p>
<%
var remoteAddr = Request.ServerVariables("REMOTE_ADDR");
remoteAddr += "";
if ((remoteAddr.length > 5) && (remoteAddr.substr(0,7)=="140.114") ) {
    Response.Write("Hello there Tsingda student!");
    }
    else {
    Response.Write("You're not a Tsingda student!");
    }
%>
</p>

<form action="./FiboRecursive.asp" method="post">
<input type="submit" value="Calculate Fibonacci numbers!" />
</form>

<!--#INCLUDE FILE="fiborecursive.asp" --> 

</body>
</html>

This is the code in FiboRecursive.asp:

<%@ language="javascript" %>
<%
Response.Write("Let's calculate some Fibonacci numbers!");
%>

Edit: Another thing: I always use web developer tools (error console) in Firefox to check for errors in my code, but obviously that doesn't work too well when doing server side stuff. Any way to get some hints as to what's wrong from a console or similar?

Lurifaxel
  • 674
  • 6
  • 17
  • Your include looks okay, I prefer a virtual include myself, but that shouldn't be an issue. What is the error you get? To answer your other question, it is possible to use Visual Studio to debug classic ASP. You can add a "STOP" keyword (or "debugger" in jscript) to stop the code, jump to visual studio and execute line by line examining variables if you want. There are some things to setup in IIS as well, you need to enable debugging for your site. – Erik Oosterwaal May 14 '12 at 08:48
  • Thanks for commenting, and the info! The error I get in IE is HTTP 500 - internal server error. This is translated from swedish so it's probably not letter for letter what it says in english. – Lurifaxel May 14 '12 at 11:16
  • Ah, IE has a setting called "show friendly HTTP errors", under Internet options - advanced - View webpages. You should turn that off. If IE gets an HTTP 500 (server error) it shows you a generic text instead of the actual ASP error that is occurring. Also in IIS you should enable client side and server side debugging and "send errors to browser" - http://stackoverflow.com/questions/1395277/debug-classic-asp-via-iis-7 – Erik Oosterwaal May 14 '12 at 11:38
  • FINALLY some proper help with debugging, geez! Thanks alot for the help! =) – Lurifaxel May 14 '12 at 11:48

1 Answers1

2

You should not have the @ command within your include file as this will (in ISS version 5.1 at least) result in the following error:

Error Type:
Active Server Pages, ASP 0141 (0x80004005)
The @ command can only be used once within the Active Server Page.
Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84