Tuesday, 28 April 2015

Model View Control 

Model View control generally referred as MVC. This is one of the best software design pattern.
MVC is a architectural pattern where the base core module is divided into three distinct layers
That is Model , View and Control.

This MVC three layer architecture is different from what we have already have seen in asp.net 3 Tier Architecture.

3 Tier Architecture  

This three layers are inter dependent means if one layer is change other two get effected so this are sequential  operation. This three layer are like presentation layers  where UI are Interfaces are used to interact with user and Logical layer this is used for business logic and Data Layer this is used for accessing the data from the data bases.



MVC Architecture

This also Three Layers similar to 3 tire architecture but they are much different from each other so the MVC Layer are are not dependent each other are they are independent to each other so that can be explained as following
 

In the above Figure we have seen the interaction between controller model and view but in MVC there is no interaction between Model and View but in some other architecture pattern like MVVC we have interaction with model that is big a controversial topic.But in MVC the controller will interact with model and view.

So MVC Architecture is used in different platform like PHP, Ruby on Rails,Apple ISO and Asp.Net MVC.

So let see more into Asp.Net MVC. why we call Asp.Net MVC because this is the extension of the base core Asp.net frame work so its called as Asp.net MVC.

After MVC came into picture we have lot of development in MVC compare to asp.net.

What is ASp.Net MVC ?

In Asp.net MVC we use mainly Razor as programming Language for creation of the web pages so we will see the examples based on the Razor Syntax.

ASp.net MVC is mainly dividing the application into three section as following :

1.Model :
Model is like business logic for the application and its used for handling the data bases related action.
models are used for getting and setting the data into data bases.its a basically a class which as all the data bases tables elements:

for example we have a table which has all the information about a employee the model may be as following :

public class Auction  
        public Int32 aucid { get; set; }

        public string Aucname { get; set; }

}

 so this model is used for retrieving the information and also for inserting the data into data bases.

2.Controller :
Controller is like supervisor means when any request come it will decide which model to invoke and it will send the model to view and view will render the model and send the responses to controller and it is send back to user.

For example we will the controller


So as we have seen the controller so all the controller names ends with Controller so i have created a controller as auctions so its is shown as AuctionController and other is the action method it calling like index so if the request come like this www.URL/Auctions/index we will get the page what we requested.So the Controller will return the view what the user have requested as shown as above.

View :
This View is used for rendering the Controller specified  model into html.So in Razor Syntax all the pages are saved as cshtml so that means we have code behind and html at the same place.


so above is the index.cshtml so this action method is called when the Auction controller calles the index action method.

So the URL as following http://URL/auctions/index
So when you request the above page we will get the following page as shown below


This Blog is to give a quick view to what is MVC so please go through more topics like Razor its coding syntax and so on.