Sep 25, 2015

Creating a MVC Application

we’ll be building a simple web app for “Movie Review” where in I’ll walk you through all the tiny steps involved in building the site. So, let’s get started. Before we begin, we must install the prerequisites for making this app. Now, to create a MVC Application, open the Visual Studio, click on New Project and select the below mentioned project as shown in the snapshot.








Note: - Here am using Visual Studio 2013 Ultimate Version.
Now, as soon as you select the MVC 4 web application, it will present couple of differentapplication templates option as shown ahead in the screen shot.





Empty Template:- Empty template will just have the basic folder structure that’s it and nothing more than that.

Basic Template:- The basic template will give you the MVC infrastructure in the solution.However, basic templates are for experienced MVC guys who want to customize the solution their way.


Internet Application:- Internet Application is the one which I am interested in as you can see in the above screen shot. However, it will give all the required dependencies in my solution structure to get started with my web application.
Intranet Application:- Intranet application is the one which deals with Windows Authentication. So, once you select this option, your app gets automatically configured with windows related settings.


Mobile Application:- Mobile application is the one which is included with MVC 4. The mobile application is preconfigured with JQuery Mobile. It helps developer to create just mobile sites. It includes themes which is supported by mobiles, touch enabled UI etc.


Web API: - Web API terminology will be discussed in detail later in this book. However, for now you just need to know that Web API is basically a framework which supports creating HTTP services.


Single Page Application: - SPA is a new terminology which offers building Single Page Application, focused mainly on client side interactions using tons of JavaScript and different JS Frameworks like Knockout, Durandal, Angular etc. This kind of web application is highly


interactive and feature rich for ex: - Gmail, Outlook etc.


Facebook Application: - Facebook application is I would say a kind of API support which offers developer to use the Facebook API in their application to build a Facebook centric website. This is really a cool stuff. 


Now, the next option which I have selected above is razor as view engine, so if I click on this dropdown I could see two options available as Razor and ASPX.



I also have a habit of checking Unit Test Project as you can see below in the screen shot. So, upon checking this checkbox, Visual Studio will create o n e more project for me in thesolution which is going to be Test project. Here, I can go ahead and write my test cases against any specific module or scenarios






 So, when you click on the dropdown of Test framework, you will see only one test framework in there. However, Microsoft has given an option to developers to install their friendly testing framework like NUnit, XUnit, etc. So, once these frameworks will get installed, this will get added in the dropdown box.

How MVC Applications are Structured:-
 
Below is the snapshot of the MVC application structure. This gives a brief idea that how your simple MVC app is structured initially.








Below I have listed specific directories which are there in the solution and their meaning.

Models:- Section containing all the classes related for fetching the data and manipulating the same.


Views:- Section containing all the UI related stuffs. These are the ones which are going to be rendered based on controller’s action.


Controllers:- Section where in the entire controller classes are placed which basically handles all the incoming requests from the browser.


Scripts:- Section where in all the scripts related stuffs are placed.


Images:- Section where in all the images are placed which is used across your site.


Filters:- Section where in all the filters are placed. We’ll do deep dive usage of filters later in coming chapters.


App Data: - Section where in all the data files are stored meant for reading and writing the same.



App Start: - Section where in all configurable stuffs resides like Web API, Routing etc.


Note: - This is basic internet app MVC structure. However, please note that MVC Framework never enforces any kind of folders organization. You can obviously customize the folders your way, like in many enterprise projects Models go in a separate class library project just to make sure reusability. However, you could do higher level of separation, it entirely depend on you.




No comments:

Post a Comment