当前位置:网络资源中心文章中心网络编程ASP教程 → 文章内容

让使用者可以看到你的ASP的原代码 (1)

减小字体 增大字体 作者:小猪  来源:网咯收集  发布时间:2008-5-16 9:46:56
假如你写了一个ASP的程序,希望让你的使用者看到ASP的原始代码,你可以利用FileSystemObject这个对象送出程序原始代码.
%26lt;%@ Language=VBScript %%26gt;
%26lt;%Option Explicit %%26gt;
%26lt;%
Dim strURL
strURL = Request.QueryString(%26quot;URL%26quot;)

Dim strDir, strFileName
strDir = Request.ServerVariables(%26quot;APPL_PHYSICAL_PATH%26quot;)

Response.Write strDir

strFileName = Replace(strURL,%26quot;/%26quot;,%26quot;\%26quot;)
strFileName = strDir %26amp; strFileName

Const ForReading = 1
Dim objFSO, objTextStream
Set objFSO = Server.CreateObject(%26quot;Scripting.FileSystemObject%26quot;)
Set objTextStream = objFSO.OpenTextFile(strFileName, ForReading)

Response.Write %26quot;%26lt;HTML%26gt;%26lt;BODY%26gt;%26quot;
Response.Write %26quot;%26lt;XMP%26gt;%26quot; %26amp; objTextStream.ReadAll %26amp; %26quot;%26lt;/XMP%26gt;%26quot;
Response.Write %26quot;%26lt;/BODY%26gt;%26lt;/HTML%26gt;%26quot;

objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing

%%26gt;