2010-12-17 60 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