ASP.NET,C#.NET,VB.NET,JQuery,JavaScript,Gridview,SQL Server,Ajax,jQuery Plugins,jQuery UI,SSRS,XML,HTML,jQuery demos,code snippet examples.

Breaking News

  1. Home
  2. ASP.NET MVC
  3. What is MVC

What is MVC

MVC is a software architectural pattern that separates the structure and behavior of the applications. It does this by partitioning the application into three component/parts: model, view and controller. MVC pattern is widely used in software development with many programming language like: java, C#, C, C++, PHP etc.  This article explains an introduction to Model View Controller MVC pattern. Summary of the article:
  • What is MVC?
  • What is Models?
  • What is Views?
  • What is Controllers?
  • History of MVC
What is MVC?
The MVC (Model View Controller) is a design pattern used in software engineering. These patterns propose there components or object to be used in software development:
  1. Model
    Model is the data access layer. This can be direct data access, web services, etc
  2. View
    View is the presentation layer of the application. This the users interface.
  3. Controller
    Controller is the business logic layer for the application. It controls Models & View.
MVC is a pattern for organizing codes in an application to improve maintainability. For understanding consider a photographer with his camera in a studio. A customer asks him to take a photo of his car. Here, car is the model, camera is the view, and photographer is the controller. All are completely independent. The car does not know anything about the photographer or the camera. This separation allows the photographer to go around the car and point the camera at any angle to get the shot/view that he wants.
In non-MVC architectures, every thing is integrated together tightly. If the car, the photographer and the camera were one object then, for a new view we would have to re-build the car and the camera.
Models
A model represents the logical structure of data.
Views
A view is the visual presentation of its model.
Controllers
A controller controls the model and view. It is the link between the system and a user. It help users to provide input.
History of MVC
For the first time MVC Architecture was implemented by Trygve Reenskaug at 1979. It was implemented on Smalltalk at Xerox labs. The coders and software engineers accept the benefits and advantages of this architecture
That’s all about Model View Controller.

What is ASP.NET?
ASP.NET is a framework for building web pages and web sites with HTML, CSS, JavaScript and server scripting. It follows object oriented programming approach. It is not a programming language. If we write code in note pad and run it we will get output. It is a server side technology. It uses all .NET compatible language such as C#, VB.NET, J# etc. If we write our code in any language after compilation .NET convert it into MSIL.
What are the Development Models in ASP.NET?
ASP.NET supports three different development models. Such:
  1. Web Pages– It is a Simplest ASP.NET model. It is Similar to PHP and classic ASP
  2. MVC (Model View Controller)– MVC separates web applications into 3 different components: Models for data,Views for display,Controllers for input
  3. Web Forms -The traditional ASP.NET event driven development model

What is ASP.NET MVC?
ASP.NET MVC is a web development framework developed by Microsoft Corporation. It is based on MVC (Model-View-Controller) architectural design pattern. ASP.NET MVC allows software developers to build application.
History of ASP.NET MVC
The first versions (ASP.NET MVC1) of ASP.NET MVC were released on 2009.
Versions of ASP.NET MVC
The different versions of ASP.NET MVC frameworks are given bellow:
ASP.NET MVC 1
ASP.NET MVC 2
ASP.NET MVC 3
ASP.NET MVC 4
ASP.NET MVC 5
ASP.NET MVC 6
Different Features of ASP.NET MVC
Microsoft ASP.NET MVC framework has different versions. Most of the versions support most of the features of old version. Every version has introduced some new features. Some features are given bellow:
ASP.NET MVC 1
  • Support core MVC features
ASP.NET MVC 2
  • Support master page
  • Support dependency injection
ASP.NET MVC 3
  • Introduce Razor as a new view engine
  • Support multiple view engine
  • Introduce template for HTML5 and CSS3
  • Improved model validation
  • Improved dependency injection and global action filters
  • Partial page output cashing
  • Support rich JavaScript with unobtrusive, jQuery Validation, and JSON binding
  • Integrated Scaffolding system extensible via NuGet
ASP.NET MVC 4
  • Introduce ASP.NET Web API
  • Introduce mobile project template
  • Introduce entry project template
  • Support windows azure SDK1.6
  • Support for adding controller to other project folder
  • Supports asynchronous controllers
ASP.NET MVC 5
  • MVC default template is replaced by Bootstrap
  • Support authentication filters for authenticating user by custom or third-party authentication provider
  • Integrated attribute routing
ASP.NET MVC 6
  • Offer single programming model
  • More optimized for cloud computing
  • Support JSON based project extension
Difference between ASP.NET WebForms and ASP.NET MVC?
The ASP.NET WebForms and ASP.NET MVC are not exactly same. Both are different. A comparison between ASP.NET WebForms and ASP.NET MVC is given bellow:
ASP.NET WebForms
  1. It uses Page controller pattern approach for rendering layout. That means every page has its own controller (code-behind page)
  2. Page size is big. Because it has large viewstate
  3. Testing is difficult.
  4. It is good for small scale of application and limited team size.
ASP.NET MVC
  1. It uses Front Controller approach. That means a common controller for all pages.
  2. Page size is small. Because, it has no viewstate.
  3. Testing is easy.
  4. It is good for large scale of application with large team size.
What is Routing in ASP.NET MVC?
In typical ASP.NET application all the incoming requests are mapped to physical files such as .aspx file. ASP.NET MVC framework uses friendly URLs that are not mapped to physical files. It uses a routing engine that maps URLs to controller. We can define our routing rules for the engine so that it can map incoming request URLs to appropriate controller.
In a browser for an ASP.NET MVC application when a user type a URL and presses “go” button, routing engine uses routing rules that are defined in Global.asax file and find out the path of corresponding controller. Routing is an excellent feature to create human friendly and Search Engine Optimized URL’s.
What is a View Engine in ASP.NET MVC?
View Engines are used to create HTML from our views to the browser.  Usually Views are a combination of HTML and different programming language. The view engine templates have different syntax for implementation. Currently there are few numbers of view engines are available for MVC. The top four view engines are ASPX, Razor, Spark and NHaml.
What are the Benefits of using ASP.NET MVC?
Microsoft ASP.NET MVC framework provides lot advantages over traditional web application development.  The benefits of ASP.NET MVC frameworks are given bellow:
  • Separation of layer. If we write our code in a class file instead of code-behind page we can reuse the same code.
  • Page size is small. Because, it has no viewstate.
  • Testing is easy. Automated UI testing is possible.
This is all about ASP.NET MVC Overview.

No comments