1. What is MVC?
Answer: On of the most popular framework or we can say pattern is Model View Controller. It’s just like three tire architecture. This bifurcate our application in three different part or we can say layer which is presentation layer, business Layer and Data Access Layer.
Here we understand theree combination Model, View, Controller One by one.
As I mentiion above its three tier architecture design so here I explain why its three tire architecture.
1) View: – View is our presentation layer. Means what ever end user see or interact with our application is just View. In simple manner we can say it’s our forms either web or windows. If we taking about asp.net application or we application views are just our html Pages which we created normally. It’s not dependent on application Logic
2) Controller: – Controller is the part which decides which view should be render when user asks for some request. Or we can say it handle end user interaction.
Suppose I have requested “home.aspx” then its goes to controller and controller will decide which view he has to show to us. It’s our middle layer which we can business logic Layer.
3) Model: – Model is combination of our Database Layer + Business layer. It’s interacted with database like save, update, delete etc and also perform business logic.
So above are simple definitions for model view controller.
Now see below fig
In The figure you find three different entities. But there are some how dependent with each other
I will explain with the example let supposes a user request for customer data form.
Then the request first goes to controller and now controller is responsible to show a view
Suppose the view name is customerView.aspx then this view will be shown to the end user. Now what is the role of model here so model will provide data to view.
Question: – why we use this?
Re use of code this first and most important advantage of MVC architecture. It’s single for web and windows we have to just change the views.
Suppose a company wants software of inventory on both windows and web then you don’t need to write whole code 2 times instead of this you have to write 2 views while model and controller will same for both. This is first and most important benefit.
Secondly Its give proper separation between presentation layer, Business layer and Data Layer.
As This blog is mainly for Asp.net and Sql Server so I will tell you for MVC dot net provide a new project template in Asp.net 3.5 which is Asp.net MVC project.
Now you thinking what earlier for previous version so here I will tell in earlier version dot net 1.1 Microsoft provide MUIAB (Microsoft User Inter Application Block) I will provide information an example for this in my next post.
Microsoft Asp.net 3.5 MVC project Support TDD (Test Driven Development) this is another most useful feature.
MVC use core html control which we used in asp classic (3.0) like Input, button so it is much faster then our web form application.
Microsoft Asp.net 3.5 project use URL is such a way which helpful in SEO (Search Engine Optimization).
Question: – why we don’t use it?
Again it’s depend on person to person according to there requirements or there preference that whether he want to use this pattern or not. According to me (as my experience and read from other articles) there is few disadvantage of using it.
The first and most important disadvantage which I feel is limitation in controls in direct use. There are many server controls link data Grid, List control which we used in web form project can not use directly in MVC project.
Lot of work in pure HTML which is some time irritating for the programmer who earlier works on asp. Net’s web form application with server controls.
In Next article we read basic of MVC (Model View Controller). Advantage & Disadvantage. In Next Session. I come with the example how we create a simple MVC project with asp.net 3.5
Till than friends do take care your self
Enjoy dot net
Enjoy MVC
Thanks & Esteemed Regards
From one and only one your Host 🙂
Rajat Jaiswal