我在我的一个老的asp经典页面中发现了一行以//开头的vbScript代码,这是一个错误(用//而不是‘来注释一行)。
无论如何,我注意到错误的注释行可以作为正确的注释行。有人知道为什么吗?非常感谢列奥纳多
我从旧代码中取了一个小例子:
<%
Response.Write "<u>testAsp.asp</u><hr/>"
V_Password="pwd"
//V_Password = Str2Hex(V_Password)
Response.Write "V_Password=" + V_Password + "<br/>"
Response.Write "V_Password(hex)=""" + Str2Hex(V_Password) + """"
function Str2Hex(s)
' -- converte stringa di byte (non caratteri ascii!!) in formato esadecimale
'
' The Asc function returns the ANSI character code corresponding
' to the first letter in a string.
' The AscB function is used with byte data contained in a string.
' Instead of returning the character code for the first character,
' AscB returns the first byte.
' AscW is provided for 32-bit platforms that use Unicode characters.
' It returns the Unicode (wide) character code, thereby avoiding
' the conversion from Unicode to ANSI.
dim k, out, MultiByte
out=""
for k=1 to len(s)
'response.Write("|" & hex(ascb(Mid(s,k,1))) & "|<br>" & vbCrLf)
out=out & hex(ascb(mid(s,k,1)))
next
Str2Hex="0x" & out
'response.write(out & vbCrLf)
end function
%>这是生成的输出:

正如你所看到的,asp页面是用vbScript编写的,也包含了正确的vbscript注释……
发布于 2020-04-04 17:50:08
更新
因此,自从您发布示例代码并确认代码在Classic ASP环境中运行没有错误并且看起来像是注释之后,我做了一些深入的研究。
但我可以确认的是,这是特定于经典ASP环境的。如果我尝试使用wscript.exe而不是Classic ASP作为主机来运行示例,我会得到以下错误;
Microsoft VBScript编译错误:需要语句
我能得出的唯一结论是,这是同时支持VBScript和JScript的特殊副作用,这意味着ASP预处理器不会导致VBScript运行时抛出编译错误。
这可能是一个从未被发现的意外,因为页面并没有像本机运行VBScript那样强制出现编译错误。
繁荣的原始答案
可能是Classic ASP页被设置为使用JScript而不是VBScript。这两种语言都可以作为默认的活动脚本语言。
由于默认情况下使用的脚本语言可以在IIS网站级别设置,而不是使用@language指令或<script runat="server">块,因此可能并不总是清楚正在使用的是什么。
VBScript中的注释有两种风格,即Rem语句和'字符。以任何一种方式开始一行代码都会阻止在脚本中执行该代码。
REM This is a comment
'This is also a comment
Response.Write "Hello"JScript中的注释也有两种风格,一种是单行注释的//,另一种是跨多行的/* */。
// This is a comment
/*
This is also a comment
*/
response.write("Hello");有用的链接
https://stackoverflow.com/questions/61024463
复制相似问题