Razor has its own comment syntax which begins with @*
and ends with *@
.
Inline Comment:
<h1>Comments can be @*hi!*@ inline</h1>
Multi-line Comment:
@* Comments can spread
over multiple
lines *@
HTML Comment
You can also use the normal HTML comment syntax starting with <!--
and ending with -->
in Razor views. But unlike other comments, the Razor code inside a HTML comment is still executed normally.
@{
var hello = "Hello World!";
}
<!-- @hello -->
The above example produces the following HTML output:
<!-- Hello World! -->
Comments within a code block:
@{
// This is a comment
var Input = "test";
}