Default ViewEngine in MVC
In this article we are going to see what is a ViewEngine in MVC and what is it used for. The advantages and disdvantages of Default ViewEngine that comes with Visual Studio MVC framework and the different types of ViewEngines available.
In this article we are going to see what is a ViewEngine in MVC and what is it used for. The advantages and disdvantages of Default ViewEngine and the different types of ViewEngines available.
What is ViewEngine
View Engine provides the ability to controller to translate views into HTML.
When you install VisualStudio 2010. The default ViewEngine "WebFormViewEngine" already comes with it. It extends ASP.NET's Page class for its views. Therefore it uses most of the features of ASP.NET to parse and render the view content.
It implements the IViewEngine interface and it is more powerful.
It uses the same extensions as asp.net. For Ex:.aspx for views, .ascx for partial views and .master for master pages.
It allows views to be written in the same syntax used in ASP.NET web forms.
The WebFormViewEngine is in the System.Web.Mvc.dll
Ex:To Html encode an output value we use below syntax in asp.net 4.0
1.It is part of ASP.NET MVC framework.
2.Easier to learn
3.Web developers can use their web development experience to work with MVC views
1.Since it is dependent on Page class, It is bit tough to test.
2.The syntax is little confusing.
Other View Engines
apart from WebFormViewEngine, There are other ViewEngines available:
Spark View Engine,NHaml View Engine, Razor and others.
Each ViewEngine has its own advantages and disadvantages.