2010-12-17 55 views
31

使用ASP.NET MVC的默认视图引擎,你可以宣布一个服务器端的评论是这样的:如何使用Razor视图引擎声明评论?

<%-- This is a comment --%> 

此注释只会在服务器端可见,而不是发送到客户端。我将如何对Razor视图引擎进行相同操作?

+1

[Razor评论语法]的可能重复(http://stackoverflow.com/questions/3382903/razor-comment-syntax) - 当您问这个问题时,在相关问题框中这是正确的 – jfar 2010-12-17 03:59:56

+0

[Razor评论语法](http://stackoverflow.com/questions/3382903/razor-comment-syntax) – 2017-01-24 14:46:43

回答

63

@*开始注释块,以*@结束注释块。

到C#(/**/)类似

@* single line comment *@ 

@* 
    this is a comment 
    this is another 
*@ 

更多关于the Gu's blog剃刀意见。

+1

谢谢,这就是我正在寻找。奇怪的是,我的搜索没有出现在Scott Gu的博客上。 – 2010-12-17 03:57:34

+0

有了这个,我们不能在块注释中做单行注释。 – SMUsamaShah 2016-02-01 18:59:15