Use Comments in Asp.Net MVC Razor View Example

  Keywords : How to write comments in mvc razor view, Define comments in razor view, mvc comments in razor view

Commenting in Razor view is little different than c# comments. In C# we use (“//") for commenting but in Razor we will define comments like ("@*  *@"). 

Syntax for Commenting in Razor View

The syntax of comments in razor view will be like as shown below 


@* This is a Razor multiline comment *@

This razor view syntax (“ @*  *@") tell that code inside this should be ignore from being executed. This syntax is common for both and c# language using Razor. 

Shortcut to Comment Block

The shortcut for Razor Commenting are similar to C# shortcut that would be like as shown 


Comment the block - ( Ctrl E, C)

Uncomment the block - ( Ctrl E, U)


Following examples will show how to use razor comments in mvc applications


Following example shows how to use comments in mvc razor view 









Following is another example to use comments in mvc razor view 


This way we can use comments in razor view applications in mvc.