To do commenting in Razor view is a little different than C# comments. In C# we use
(“//") for commenting but in Razor, we will define comments like this ("@* *@").
The syntax for Commenting in Razor View
Syntax of comments in asp.net razor view will be shown like below
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To do commenting in Razor view is a little different than C# comments. In C# we use (“//") for commenting but in Razor, we will define comments like this ("@* *@").
The syntax for Commenting in Razor View
Syntax of comments in asp.net razor view will be shown like below
These razor view syntax (“ @* *@") tells that which code inside this will be ignored from being executed. The syntax is common for both vb.net and C# language using Razor.
Shortcut to Comment Block
The shortcut for Razor Commenting is similar to C# shortcut which would be shown
The examples will show how to use razor comments in asp.net MVC applications
Example1
The example shows how to use comments in MVC razor view
Example2
This is another example to use comments in MVC razor view
This way we can use comments in razor view applications in asp.net MVC.