Templates in Asp.Net MVC:
When we create new project in MVC by selecting “ASP.NET MVC 4 Web Application" we will get different type of project template to select like Empty, Basic, Internet Application, Intranet Application, Mobile Application, Single Page Application and Web API. In this article we will learn what these template in MVC project are and which templates we select to create new project in asp.net mvc?
There are seven type of project template available for MVC 4 application in Visual Studio 2013 ultimate.
Empty: This template is useful when we want to build mvc application from scratch. It created the minimum references and resources required to run an Asp.net MVC application. This template contain basic empty MVC folder structure with Global.asax file and App_Start folder at top and it will not contain Script folder and Content folder. You can see that Models, Controllers, App_Data are completely empty folders and View folder only contains web.config and App_Start folder contains 3 configuration files ( FilterConfig.cs, RouteConfige.cs and WebApiConfig.cs ). The folder structure of Empty Template mvc application is shown bellow
Basic: It’s a new project type in MVC 4 and it was not available in MVC3. This template is much closer structurally to Empty project template. Moreover, the basic template will contain Script folder with default script files and Content folder will have themes and site.css style sheet inside it. Bundling and minimization facilities have been prepared in this template. BundleConfig.cs file has been added to App_Start folder. As we can see that View folder has a Shared Folder in which it contains Error.aspx web form. In case if we choose Basic Template for mvc project then the folder structure will look like
Internet Application: This template is ideal for internet applications and it has built-in membership management functionality which allows you to register, login, change password and so on. It automatically adds two controllers (Account controller and Home controller) to the Basic template with implemented actions and views which is required for registration. It is completely ready application for development. In case if we choose Internet Template for mvc project then folder structure will look like
Intranet Application: This template is ideal for intranet applications and it has windows authentication. This template is ideal for intranet applications and it has windows authentication. By using this Template you can develop application for intranet based systems. In case if we choose Intranet Template for mvc project then folder structure will look like
Mobile Application: Mobile website programming is one of most important feature in MVC 4 so this template has everything that Internet Application template has, however it is using jQuery.mobile to adjust application for mobile devices and does not use the built-in authentication mechanism. Mobile application templates also come with login and registration mechanism. In case if we choose Mobile Template for mvc project then folder structure will look like
Web API: The Web API Application is yet another version of Internet application template which comes with default Home and Value controller with default View for Home controller and Value controller inherits from ApiController. It is easy to use for developing restful web services and applications to feed a variety range of clients from desktop browser to tablet applications. It allows you to expose your data and service to the web directly over HTTP. If you want to create quickly web based Service then Web API is best choice for it. In case if we choose Web API Template for mvc project then folder structure will look like
Single Page Application: Visual Studio 2012 Express or later version introduce a new template for building single page applications. For example, Mail site offers a rich user experience within single page. Navigation techniques and Ajax provide necessary functionality without a page reload.