Comparions of Razor vs ASPX syntax [closed] Comparions of Razor vs ASPX syntax [closed] asp.net asp.net

Comparions of Razor vs ASPX syntax [closed]


I think you are definitely getting confused. Your first example is not traditional asp.net. It is what the MVC render engine used to used pre-razor (MVC 1 & MVC 2 - which I believe is called the WebForms view engine).

I am very sure you cannot use a foreach in traditional ASP.Net pages. (Veli's comment corrected me on this)

With MVC 3 you can choose to use the Razor view engine which as you can see in the example is much more readable. Of course, with MVC 3 you can still choose to do it the other way, this is an option you select when creating the initial project.

You can read more about the differences here


Do any ASP.NET ASPX developers code like this?

I doubt it. Classic WebForms developers use server side controls such as repeaters.

ASP.NET MVC developers on the other hand use this syntax very much. Well, actually you could use Display Templates in ASP.NET MVC which avoids you writing ugly foreach loops.


I always thought it was bad practice to put programming code inline with the markup file, instead of the code behind file.

That's true for C# WinForm/WPF developer that use MVVM architecture. But, I think it is still good practice to put programming code inline in ASP.NET MVC.