Print Page | Close Window

Software to show complete ASP file with includes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=30284
Printed Date: 29 May 2023 at 10:33pm
Software Version: Web Wiz Forums 12.06 - https://www.webwizforums.com


Topic: Software to show complete ASP file with includes
Posted By: aussiem8
Subject: Software to show complete ASP file with includes
Date Posted: 17 April 2012 at 5:34pm
Hi guys

Reasonably new to ASP and have been wondering for a while now whether there is software that can show the full ASP code by "importing" includes to make it easier to debug programming errors.  What I mean here is that the contents of include files are expanded within the original ASP file, so you can see the entire code as the browser would interpret it.

I know I could cut and past manually, but this can take ages if you have long scripts to debug.



Replies:
Posted By: aussiem8
Date Posted: 27 April 2012 at 12:42pm
I've found some code that I modified a little to show me includes only for my site (plus with one level of nesting). 

No doubt you experienced programmers can improve on it (eg. to also show css stylesheets, deeper nested includes, open dialog box to select the file, etc.)

<%
' Target page to be read
'page_to_read = "webpage.asp"

' Create a server object
set fso = createobject("scripting.filesystemobject")

' Set the path to document to be read
set act = fso.opentextfile(server.mappath(page_to_read))

' Read the contents of the document to the
' read_text variable

'Start the page output
response.write "<pre>"

do
read_text = act.readline

'If include link exists, read that file and output
If left(read_text,20) = "<!-- #include file=""" then

    IncludeFileName = mid(read_text,21,InStr(read_text,".asp")-17)
    'Response.Write ("Filename: " & IncludeFileName)
    'ShowInclude(IncludeFileName)
   
    response.write "</br>####################################################</br>Start of Include: " & IncludeFileName & "</br>####################################################</br></br>"
    'response.write "</br>####################################################</br>Start of Include: " & IncludeFileName & "</br></br>"
    ShowInclude(IncludeFileName)
    'response.write server.htmlencode(read_text) & "</br>"
    response.write "</br>####################################################</br>End of Include: " & IncludeFileName & "</br>####################################################</br></br></br></br>"
    'response.write "</br></br>End of Include: " & IncludeFileName & "</br>####################################################</br></br></br></br>"

Else   
    response.write server.htmlencode(read_text) & "</br>"
End If

Loop Until act.AtEndOfStream

'Close pre tag
response.write "</pre>"

' Close the server object
act.close
%>

<%
Sub ShowInclude(IncludeFileName)
' Target page to be read
page_to_read2=IncludeFileName

' Create a server object
set fso2 = createobject("scripting.filesystemobject")

' Set the path to document to be read
set act2 = fso2.opentextfile(server.mappath(page_to_read2))

' Read the contents of the document to the
' read_text variable

read_text2 = act2.readall

' Close the server object
act2.close

' Write the inputted text out to the browser
' and html encode it to display as source
' enclosed in <pre> tags to display as read
response.write "<pre>" & server.htmlencode(read_text2) & "</pre>"

End Sub
%>

If anyone has a better solution/software recommendation, I'd be keen to know.


Posted By: UseAsMe
Date Posted: 07 September 2012 at 10:27am
This is what i used to do:
Rename your first .asp file to .ssi.
 
ssi uses the same syntax for includes as .asp but will not parse your asp code.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.06 - https://www.webwizforums.com
Copyright ©2001-2023 Web Wiz Ltd. - https://www.webwiz.net