While creating a new MVC project, by selecting "ASP.NET MVC 4 Web Application" we will get different project templates to select those are Empty template, Basic Template, Internet Application template, Intranet Application template, Mobile Application template, and Web API templates. We will learn what these templates are in asp.net mvc and which template we need to select to create a new asp.net mvc project by creating a simple asp.net mvc web application.
To create a new application, open visual studio (Here we are using visual studio 2012), and From the Start page, select File à New à Project like as shown following image.
After that, a new dialog will pop up from that select Templates à Visual C# à Web. In the project, select ASP.NET MVC 4 Web Application and enter Name of Project “Tutorial 2” after this, click on the OK button like the following image.
After that, a New ASP.NET MVC 4 Project dialog will appear in that Asp .net provides various types of Project Templates each has various uses.
Now we will learn each template in a detailed manner.
The Empty template contains a basic empty MVC folder structure with the Global.asax file and App_Start folder at the top, and it will not contain the Script folder and Content folder. This is just an empty configuration, and you need to create an application. In case if we select Empty Template for the project, our folder structure like as shown below.
The basic template comes with an MVC folder structure that is Model Folder, Controller Folder, and View folder is empty, but the View folder has a Shared Folder in which it contains Layouts.cshtml and Error.cshtml. The basic template will contain the Script folder with default script files, and the Content folder will have themes and site.css style sheet inside it. If we select a basic template for a project, our folder structure will be as shown below.
The Internet Application Template comes with an MVC folder structure that contains default HomeController and AccountController with default View and AccountModels that are required for registration. It also comes with a Basic Login and registration Mechanism built in it. It is a completely ready application for development. If we select an internet application template, our project folder structure will be as shown below.
The Intranet Application Template is a little bit similar to the Internet application Template. It has a default Home controller with a related View in it. It also comes with built-in windows based authentication mechanism. By using this Template, you can develop an application for intranet-based systems. If we select the intranet application folder template for the project, our folder structure like as shown below
The Mobile Application Template is too similar to the Internet application template, and it comes with default Home and Account controller with default View for both controllers. Mobile application templates also come with login and registration mechanisms. DotNetOpenAuth references for external log in functionality is removed in it. If we select a mobile application template for the project, our folder structure is shown below.
The Web API Application is yet another version of the 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 used for creating HTTP based RESTful web services. Web API Template is mostly used for passing data to various clients (Mobile and tablet). If you want to create a quickly web-based Service, then Web API is the best choice. If we select the Web API application template for the project, the folder structure like as shown below
In our application, we will select respective templates based on our requirements.