ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!



Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





ASP Source Code:
<%
Dim objASPFSO, objASPFile
Dim strFileName
Dim strInput, strOutput
Dim bProcessString
strFileName = Request.QueryString("file")
strOutput = ""
' Conditional limiting use of this file
If InStr(1, strFileName, "\", 1) Then strFileName=""
If InStr(1, strFileName, "/", 1) Then strFileName=""
If strFileName <> "" Then
	strFileName = Left(strFileName, Len(strFileName) - 4)
	Set objASPFSO = CreateObject("Scripting.FileSystemObject")
	Set objASPFile = objASPFSO.OpenTextFile(Server.MapPath(strFileName & ".asp"))
	' Loop Through Real File and Output Results to Browser
	Do While Not objASPFile.AtEndOfStream
		strInput = objASPFile.ReadLine
		' If we find Begin Script Tag start processing
		If InStr(1, strInput, "<!-- BEGIN " & "SCRIPT -->", 1) Then
			bProcessString = 1
			strInput = objASPFile.ReadLine
		End If
		' If we find End Script Tag stop processing
		If InStr(1, strInput, "<!-- END " & "SCRIPT -->", 1) Then bProcessString = 0
		If bProcessString = 1 Then
			'Response.Write strInput & vbCrLf
			strOutput = strOutput & strInput & vbCrLf
		End If
	Loop
	objASPFile.Close
	Set objASPFile = Nothing
	Set objASPFSO = Nothing
	'Response.AddHeader "Content-Disposition", "inline; filename=" & strFileName & ".asp"
	Response.AddHeader "Content-Disposition", "filename=" & strFileName & ".asp"
	'Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName & ".asp"
	'Response.ContentType = "application/rtf"
	'Response.ContentType = "application/save"
	Response.ContentType = "application/octet-stream"
	'Response.ContentType = "application/unknown"  ' Causes security zone issues in IE4
	'Response.ContentType = "application/asp"      ' Causes security zone issues in IE4
	Response.Write "<" & "%" & vbCrLf
	Response.Write "'*******************************************************" & vbCrLf
	Response.Write "'*     ASP 101 Sample Code - http://www.asp101.com     *" & vbCrLf
	Response.Write "'*                                                     *" & vbCrLf
	Response.Write "'*   This code is made available as a service to our   *" & vbCrLf
	Response.Write "'*      visitors and is provided strictly for the      *" & vbCrLf
	Response.Write "'*               purpose of illustration.              *" & vbCrLf
	Response.Write "'*                                                     *" & vbCrLf
	Response.Write "'* Please direct all inquiries to webmaster@asp101.com *" & vbCrLf
	Response.Write "'*******************************************************" & vbCrLf
	Response.Write "%" & ">" & vbCrLf
	Response.Write vbCrLf
	Response.Write strOutput
Else
	' Response.Write "Can't find that file!"
	Response.Write "Nothing to see here!"
End If
%>

Back the the Sample Output

Back to the Sample Index


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers