为什么经典的ASP服务器端包含在注释中? [英] Why is the classic ASP server-side include enclosed in a comment?

查看:53
本文介绍了为什么经典的ASP服务器端包含在注释中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么服务器端包含<!--#include file="suchandsuch"-->的语法?

Why is the syntax for server-side inclusion <!--#include file="suchandsuch"-->?

将具有语义意义的内容放在评论中似乎很尴尬且具有误导性-确实,当我第一次看到这种语法时,我以为它是一个被注释掉"的包含项.与<% #include file="suchandsuch" %>之类的替代方案相反,设计使用该语法的语言的背后原因是什么?

Placing semantically meaningful content inside a comment seems awkward and misleading – indeed, the first time I saw this syntax, I assumed it was an include that had been "commented out". What was the reasoning behind designing the language to use this syntax, as opposed to alternatives like <% #include file="suchandsuch" %>?

(我知道,使用简单替换来解析该示例替代项将呈现类似<% <% vbscript_stuff %> html_stuff %>的内容,但是更智能地对其进行解析以免滥用HTML注释应该是微不足道的.)

(I'm aware that parsing that example alternative with simple substitution would render something like <% <% vbscript_stuff %> html_stuff %>, but it should be trivial to parse it a little more intelligently to avoid misusing HTML comments.)

推荐答案

我认为主要原因是在服务器端包含的情况下,服务器端处理直接由IIS处理,然后传递给处理引擎,其内容相关

I think the main reason is the server side processing in the case of server side includes is handled directly by IIS then passed off to the processing engine the content is related to.

因此,使用问题中的示例,语法是否;

So using the example in the question, if the syntax was;

<% #include file="suchandsuch" %>

然后直接处理ASP处理语法,这意味着SSI定义不再是通用方法.

then it's dealing direct with ASP processing syntax which means the SSI definition is no longer generic in it's approach.

MSDN库文档中所述

As stated in the MSDN Library documentation

此伪指令可在ASP页,STM页,INC页或任何文件扩展名映射到SSI解释器(Ssinc.dll)或ASP解释器(Asp. dll).如果已安装IIS管理器,则可以修改默认的应用程序映射并添加新的映射.

由于<!-- -->注释是在服务器端处理的,因此它永远不会到达客户端的浏览器,因此HTML语义不会受到影响.

Also as the <!-- --> comment is processed server side it never reaches the client's browser so HTML semantics are unaffected.

有用链接

  • IIS: Notes on Server-Side Includes (SSI) Syntax (KB 203064 Revisited)

这篇关于为什么经典的ASP服务器端包含在注释中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆