经典ASP页面在浏览器中显示注释的代码块

时间:2019-03-28 09:18:10

标签: vbscript asp-classic

我有一些经典的ASP页面可供用户查看。但是有些用户可以在浏览器中看到一些注释代码

示例:

****************** 'New Setup ******************

我已经检查了Google Chrome和IE10。如何解决此问题?

1 个答案:

答案 0 :(得分:1)

经典ASP是一种服务器端处理语言,在任何输出发送到客户端之前,服务器都会处理在其预处理器标签<% %>之间编写的此类代码。

要修复此评论,请将其添加到预处理器标签中;

<%
'****************** New Setup ******************
'Code here will run server-side
Response.Write "Hello" 'Will write hello to the client.
%>
<!-- 
Both this comment and the line below are treated as HTML
and will output once the server-side processing has finished.
-->
World

输出:

Hello<!-- 
Both this comment and the line below are treated as HTML
and will output once the server-side processing has finished.
-->
World

另外,请记住,VBScript注释以单撇号'开头,否则它将尝试运行注释文本。