View Engine
Rendering of the view into HTML form to the browser is done by view engine in ASP.NET MVC.
ASP.NET MVC supports various types of view engines but commonly used view engines are :-
- Web form / ASPX view engine
- Razor view engine
The functionality of above two view engines is almost same but have a lot of difference between them :-
Web form / ASPX view engine
- This view engine was introduced from MVC 1.0. By default, this view engine is available in ASP.NET MVC.
- System.Web.Mvc.WebFormViewEngine is the namespace for this view engine.
- The Web form file extensions are different from razor view engine extensions. Following are the extension used :-
.aspx - views
.ascx - partial views and editor templates
.master - layout/master pages
- Delimiters <% and %> are used by this view engine. Example of Web form view engine is @Html.ActionLink("Login", "Login") .
- Cross-Site Scripting attacks are not prevented i.e any saved script in the database is fired when a page is rendered.
- Design mode is supported by Web form view engine in visual studio i.e how the page look can be seen in advance without running the application.
- This view engine is faster than razor view engine.
- Test Driven Development is not supported by this view engine.
Razor view engine
- A new markup syntax was introduced in MVC3 and was referred as razor view engine. It is an advanced view engine.
- System.Web.Razor is the namespace for this view engine.
- The razor view engine file extensions are as follows :-
.cshtml - razor with c#
.vbhtml - razor with VB
The above extension are used for views, partial views,editor templates and layout/master pages according to the language selected.
- @ symbol is used by Razor view engine. Example of razor view engine is @Html.ActionLink("Login", "Login").
- Prevents Cross-Site Scripting attacks by default.
- Design mode is not supported by razor view engine in visual studio i.e how the page look cannot be seen in advance.
- This view engine is slower than Web form view engine.
- Test Driven Development is supported by this view engine.
0 Comment(s)