asp.net.mvc中的@*运算符是什么意思?

What is the meaning of @* operator in asp.net.mvc?

我是 ASP.NET MVC razor 引擎的新手。

我想知道在cshtml代码中html片段之前使用@*的meaning/purpose?

这是一条评论

@* this is commented code in a .cshtml file*@

.cs 文件中与此类似

/*this is commented code in a .cs file*/

它标志着 comment 的开始。它以相应的 *@ 符号结束

What is the meaning of @* operator in asp.net.mvc?

与ASP>NET MVC无关。它特定于 Razor View Engine。它用于注释输出中跳过的代码或标记的特定部分。

所以如果你这样做

@* Some Tags or Code *@

这只是服务器端的评论。此外,此语法指示 Razor 解析器应忽略该块中的所有内容并将其视为根本不存在(意味着什么都不会执行,在运行时没有性能开销,并且不会将任何内容发送到客户端) .

这个用来注释代码

@* Your code here to comment *@

visual studio 键盘快捷键:
select 您要评论的部分,然后按:CTRL + K + C 将注释代码。
CTRL + K + U 将取消注释代码。



对于那些正在寻找 .aspx view engine 页的人。

<%-- Your code here to comment --%>