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
<%:Model.Content %>

Advantages

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
Disadvantages
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.


Article by Vaishali Jain
Miss. Jain Microsoft Certified Technology Specialist in .Net(Windows and Web Based application development)

Follow Vaishali Jain or read 127 articles authored by Vaishali Jain

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: