Vijay
Vijay

Reputation: 523

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

I am a newbie to ASP.NET MVC razor engine.

I would like to know the meaning/purpose of using @* before the html fragment in cshtml code?

Upvotes: 6

Views: 11123

Answers (4)

Rahul Nikate
Rahul Nikate

Reputation: 6337

This is used to comment the code

@* Your code here to comment *@

The visual studio keyboard shortcut :
select the section you want comment and press : CTRL + K + C will comment code.
and CTRL + K + U will uncomment the code.



For those who are looking for .aspx view engine pages.

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

Upvotes: 4

Bhushan Firake
Bhushan Firake

Reputation: 9448

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

It has nothing to do with ASP>NET MVC. It is specific to Razor View Engine. It serves as to comment specific part of code or markup which is skipped in output.

So if you do

@* Some Tags or Code *@

It will just be a comment at server-side. Additionally, this syntax indicates that the Razor parser should ignore everything within that block and treat it like it isn’t there at all (meaning nothing is ever executed, there is no performance overhead at runtime, and nothing is sent down to the client).

Upvotes: 2

Wolfwyrd
Wolfwyrd

Reputation: 15906

It marks the start of a comment. It's closed with the corresponding *@ sign

Upvotes: 2

Igor
Igor

Reputation: 62213

Its a comment

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

Similar to this in a .cs file

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

Upvotes: 16

Related Questions