How do you declare a comment using the Razor view engine? [duplicate]
Asked Answered
Z

1

36

Using ASP.NET MVC's default view engine, you can declare a server-side comment like this:

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

This comment will only be visible on the server side and is not sent to the client. How would I do the same with the Razor view engine?

Zootechnics answered 17/12, 2010 at 3:48 Comment(0)
W
71

Start the comment block with @*, end the comment block with *@.

Similar to C# (/* and */)

@* single line comment *@

or

@*
    this is a comment
    this is another
*@

More on Razor comments on the Gu's blog.

Whipstock answered 17/12, 2010 at 3:51 Comment(2)
Thanks, that's exactly what I was looking for. It's strange though how none of my searching turned up that post on Scott Gu's blog.Zootechnics
With this we can not do single line comments inside a block comment.Frazier

© 2022 - 2024 — McMap. All rights reserved.