.NET > Patterns >> MVC Views : 692
Rate This Article :

Introduction to MVC

Model View Controller termed as MVC is a software design pattern for developing web applications. MVC constitutes below mentioned important three parts.

  • Model

1. Model in MVC is basically class (C# or Vb.Net) which will maintain the data.

2. A Model will be accessible by both Controller and View.

3.Model will be used to pass data from controller to view

4.View will use the Model to display the data in page. 

  • View

1.View is .csHtml (or) .aspx file without having code behind file.

2.View can be made as dynamic by using server tags. Inside the server tags, user can write the code to make it dynamic.

3. Request will be made to View from controller's action method.

  • Controller

1. Like Model, Controller is a class (C# or Vb.Net) which inherits System.Mvc.Controller.

2. Controller will use Model for data manipulation and pass it to View.

3. Controller use Viewbag, ViewData to pass any type of data to View.

 

MVC Architecture:

 MVC Architecture V1.png


Flow of MVC:

MVC Architecture and flow.png

Step 1:

Client request by entering the URL in the browser. for e.g. example.com/home/index


Step 2:

MVC Routing will parse the above mentioned URL through "application_start()" method which is present in Global.asax as below.

example.com/home/index

From the above URL, MVC routing will determine the below parameters,

Controller - Home

Action - Index

Id - Empty (Since the URL doesn't have the Id, it will be considered as empty)

We can write our own routing in the existing routing method. Routing will get executed based on the priority. (i.e. routing defines at first will have top most priority)


Step 3:

Now MVC will call the "Home" controller class first (i.e. HomeController.cs) in order to trigger the specific action method. Here the action method is "Index", so it will call the Index method present in the HomeController class.


Step 4:

After coming to the "Index" action and completing business logic and populating data in the object model, MVC will call the specific view to load the UI page by passing data.

for e.g. inside an action method, calling return view() (or) view ("Home", Model) (or) view ("Index", Model) will return the specific view present in the /views/home/index.cshtml (or) Home.cshtml.

These are the process and working methodology of MVC. 

Thanks for reading, leave your comments to improve this article. In next article, we will see some basic concepts in MVC.

About Author
Raj Kumar
Total Posts 31
Developer in .Net!
Comment this article
Name*
Email Address* (Will not be shown on this website.)
Comments*
Enter Image Text*
   
View All Comments
  Privacy   Terms Of Use   Advertise With Us   Contact Us
© 2016 Developerin.Net. All rights reserved.
Trademarks and Article Images mentioned in this site may belongs to Microsoft and other respective trademark owners.
Articles, Tutorials and all other content offered here is for educational purpose only and its author copyrights.