Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "@" in ASP MVC mean/do?

Tags:

asp.net-mvc

I know this is a simple question, but I am new to ASP MVC and just can't find the answer to this anywhere - what is the "@" that I am seeing everywhere? example:

@{
    ViewBag.Title = "Welcome";
}

<h2>Welcome</h2>

<ul> 
   @for (int i=0; i < ViewBag.NumTimes; i++) { 
      <li>@ViewBag.Message</li> 
   } 
</ul>
like image 531
Ben Strombeck Avatar asked Jan 17 '23 05:01

Ben Strombeck


1 Answers

@ is a syntax element of Razor engine, that is used in ASP.NET MVC 3. Your code will show text from ViewBag.Message ViewBag.NumTimes times.

ViewBag properties are dynamic and can be populated from controller.

Take a look http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx to the Razor syntax

like image 199
xwrs Avatar answered Jan 19 '23 00:01

xwrs