Tuesday, 15 July 2014

MVC -4 View Engine

View Engine are responsible for rendering the HTML from your views to the browser. The view engine template will have different syntax for implementation. Currently there are few number of view engines available for MVC and the top four view engines are Razor, traditional ASPX, Spark and NHaml. I have written another article on comparison of different view engines.
Razor is the preferred View Engine for MVC, ASPX View Engine is the legacy View Engine and this option is there for backward compatibility.
MVC View Engine
I will be explaining more about Razor on another article.
Once you click 'OK' after selecting the appropriate project template Visual Studio will create a MVC Web Application project with default files and folders as per the Template Selection.
If look at the visual studio status bar you can see that the project creation progress and the files adding to the project. ASP.NET MVC 4 project template is using Nuget Package Manager to install and manage the assembly references in your application. the below files in status bar adding by Nuget.
Package.Config File contains the list of the Nuget Package used in this project.

Now Visual Studio created our project in place and the solution file looks like , 
MVC Web Application
I have explained the Project Items/ Application folder structure in another article, before continuing with our newly created project I just wanted to explain the Project Templates.

Project Templates

Currently MVC 4 Application in Visual Studio 2010 and Visual Studio 2012 offers 6 different types of project templates. (Previously it was 7 but the final version of MVC 4 doesn't shipped with ASP.NET Single Page Application due to some compatibility)
I will be explaining the Basic, Empty, Internet Application, Intranet Application, Mobile Application and Web API project templates here.
Empty
The Empty template created the minimum references and resources required to run an Asp.net MVC application.As you can see in below image, Models, Controllers, App_Data are completely empty folders and View folder only contains web.config and a Global.asax file and web.config.App_Start folder contains 3 configuration files ( FilterConfig.cs, RouteConfige.cs and WebApiConfig.cs ).
This option will be good if you plan to create everything from scratch.
After comparing the Empty project image and Basic project image we can say that The Basic template is somewhat similar to Empty template. In addition to the Empty project , Content , Script folder are present in this template and Shared folder is present inside Views and also in App_Start folder apart from the three files in empty template, basic template added one more file named BundleConfig.cs (Bundling and minimization).
Same like Empty Template,this option also good if you plan to create everything from scratch.
Internet Application
The Internet Application extends Basic Template with two controllers( Account controller and Home controller) with all the logic and functionality implemented in actions and views. In this template membership management functionality gives the option to user to register and login, change password etc in the website.
It's a template used usually to start a normal web project in action.
Intranet Application
The Intranet Application template is same like the Internet Application template, except that it is preconfigured to use Windows-based authentication.
This template will be a good option if you plan to create an intranet web site.
Mobile Application
The Mobile Application template is another variation of the Internet Application template. This template, however, is optimized for mobile devices and includes the jQuery Mobile JavaScript framework and views that apply the HTML that works best with jQuery Mobile.
If you plan to target touch based mobile devices then this template is the right option.
The Web API template is yet another variation of the Internet Application template that includes a preconfigured Web API controller.ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
Web API is a great choice for quickly and easily creating data services that your AJAX-enabled applications can easily consume.
If we want to create a Test project while creating the MVC project itself then we need to mark the Create Unit Test Project Check box. If you don't want to do this at the first time you can add a unit test project later also.
If we are creating MVC Application with Test project then the solution explorer will look like below .

No comments:

Post a Comment