Tuesday, 16 June 2015

ASP .NET MVC for Beginners..

What is MVC?

It is a software design pattern that splits our application into three different module, i.e. "Model","View" and "Controller". This separation helps to maintain business, data and UI layer separately.

MVC Architecture.

The following image illustrate the MVC architecture.

MVC Architecture
When a request comes, it will go to Controller. Controller acts on both Model and View. It manages the data flow between Model and View.

Model

Model is nothing but a class which maintains the structure of your data. It can be access from controller and View. View use Model to display data in page.

View

View is a user interface. Its gets data from the Model and update in the page. You can call a view from a Controller.

Controller

Controller is a class which hold a very important area in MVC and it inherits from System.MVC.Contoller base class. You can write multiple methods which can interact with Models and update data to your Views.


More....

Model,View and Controller are the subsequent folder to keep our Model class, View file and Controller class in our application.

Visual studio will automatically create these folder by default while creating your MVC application.
File Structure

In the above picture you can find the default files which are getting created while creating an application.

In Controller folder you will have Controller files and all Controller file will have .cs extensions and also all Controller file name will be preceded with Controller word, this is the naming convention for Controllers.

In View folder you will have View file which is having .cshtml extension. For respective Controller there exists a corresponding folder in side View folder.

In Model folder you will have all model class having .cs extensions.

Apart form these three folders you will have Content, Scripts folder where you can keep your style sheets and script file respectively.




No comments:

Post a Comment