ASP.NET MVC > Views - Razor Engine

For each loop in Razor in ASP.NET MVC

How to perform for each loop in Razor view?


It is similar to the for loop except that it can be done only to those collection that has similar type of objects in it as it is in C#.

<ol> 
@foreach (var variable in Request.ServerVariables)
{
<li>@variable</li>
}
</ol>

 

 Views: 23333 | Post Order: 12



Write for us






Hosting Recommendations