ASP.NET WP - View Engines

The View Engine in ASP.NET is used to translate our views to HTML and then render them to the browser. By default, ASP.Net supports ASPX and the Razor View Engine. The view engine templates have a different syntax than the implementation. In this chapter, we will discuss the two most important view engines which are −

ASPX View Engine also known as Web Form View Engine and

Razor View Engine

There are many more third-party view engines, like Spark, Nhaml, etc.

ASPX View Engine

ASPX or Web Form Engine is the default view engine for ASP.NET that is included with ASP.NET MVC from the beginning itself.

The syntax used for writing a view with the ASPX View Engine is the same as the syntax used in the ASP.NET web forms.

The file extensions are also the same as for ASP.NET web forms (like .aspx, .ascx, .master).

@foreach (var student in Students){
@if(student.IsPassed){
@student. FirstName is going to next grade.
} else {
@student. FirstName is not going to next grade.
}
}

If you look at both the above code snippets written in ASPX and Razor syntax, then you can see quite clearly that Razor syntax is clean and simpler as compared to the ASPX syntax. One of the disadvantages of Razor is, it is not supported by visual editors like Dream Viewer.