- What is MVC Framework?
- Back to the roots
- What is ASP.NET MVC Framework?
- MVC Framework Architecture
- Why to use MVC?
- Xafari MVC
- ASP.NET MVC Top Asked Questions
We can hear about MVC concept more and more frequently in the development world especially nowadays. Almost every developer connected with web application creation had to deal with MVC. So what is it about and why is it so popular?
MVC is all about User Interface and logic control, to be more precise – about how to make them more convenient. MVC - short for Model-View-Controller – is a kind of pattern, which divide app data, UI and logic control on three separate components: model, view and controller. Thus, the concept “divide and conquer” of the development world, helps us to modify each component independently.
To make it more clear let’s look at the blocks below:
Trygve Reenskaug was the scientist who described MVC for the first time in 1978. Initially the pattern was called the Thing Model View Editor but then was changed to Model View Controller. The scientist strove to find a simple way to represent complex real world systems while working on Smalltalk.
The MVC concept was published in Technology Object magazine in 1988. Then the pattern became popular with WebObjects introduction in 1996 as it was written on the Smalltalk based language. MVC also gave rise to MVA (Model View Adapter), MVVM (Model View Viewmodel), HMVC (Hierarchical model View Controller) and MVP (Model View Presenter) versions.
Now the popularity of MVC frameworks continues to grow.
In 2007 ASP.NET announced its own MVC pattern and released it in 2009. ASP.NET MVC is a Microsoft Framework, which combines MVC features and ASP.NET capabilities together. It is a kind of alternative to a standard ASP.NET Web Forms.
But in comparison with the Web Forms ASP.NET MVC Framework is more up-to-date and has the following advantages:
- It is much easier to manage the components as they are the separate units: you can modify model, view or controller without damage to the other components;
- It is also possible to test the components separately;
- Developers can control the system completely as there is no need to use server-based forms;
- Full and direct control over HTML;
- Facilitates the work of development departments: provides high control over different separate components, so designers and developers can work independently on their own parts.
ASP.NET MVC Framework has the following features:
- Easy testing: TDD (test-driven development), app tasks and testability are separated by default. It is also possible to use another testing framework adaptable with .NET Framework.
- Easily customized: you can customize, change or replace ASP.NET MVC components.
- Supports ASP.NET features: it is possible to use such ASP.NET features as health monitoring, Windows authentication, URL authorization, the configuration system and others.
- Build-in authentication and identity management: there is no need to manage identity and authentication as they are build-in and the process became simpler, flexible but secure. Moreover, authentication is possible now though Twitter, Facebook or Google.
As it was said previously, MVC means to divide app management on three separate components: control, model and view. But the question is how do they cooperate and work inside the application?
Now we are going to take a closer look at the MVC Framework architecture and to overview each component in detail.
In order to make the MVC architecture visual and clear we present it in the following pattern form:
So, as is seemed from the scheme above every component is a separate element. However, cooperation of these three components and their connection to each other makes the system work and produces the response for user’s request.
Let’s talk in more detail about every separate component now:
The first component we are going to consider is controller. It is the central part of ASP.NET MVC application. As it is clear from our scheme, the controller is the main recipient of user’s request. Then the data is processing and the suitable model is asked. Thus, the controller is responsible for the data processing in the application and suitable response output.
One more reason to name the controller an essential MVC component is that it contains the code (C# class).
Another important component is model. It is a business logic of the application, which stores and collects the data. Controller sends commands to the model in order to receive the required data and then this data displayed in the view. Thus, model is a kind of link between controller and view.
Summarizing the above mentioned, model is the tool which helps us to interact with the database and to extract the necessary information.
The view in MVC application is about user interface. This component helps user to see the result of his request. The view displays the data from the model in the appropriate way.
In ASP.NET MVC the view engine by default is ASPX file. But in case you want to work with something else you can switch your own view engine.
Since rising MVC popularity and ASP.NET MVC Framework release in 2009 it is steel something fresh and attractive for Microsoft world. More and more developers move from Web Forms to MVC. But why is it happening? Here are some reasons of ASP.NET MVC popularity after which you can decide yourself:
- Concerns separation. It is much easier to find and solve the problem when the components are separated. You can test each of them separately and solve the problem changing the single element.
- Everything is under your control. You can integrate our own business logic whether it is a reusable model or controller instantiation.
- HTML control. ASP.NET MVC does not have server side controls, so you can regulate your view size. Thus, there is possible to manipulate the page rendering in browser.
- ASP.NET MVC is an open source. The view engine creation is simple now as you can see the code with a help of Git Hub.
- Cross Platform. Use Windows, iOS or Linux for your web applications coding.
Galaktikasoft presents its own version of MVC. Xafari MVC is an extension for DevExpress XAF Framework and helps to develop applications on MVC platform easily. It solves such problems as:
- Low performance of the application
- Request delays
- Page reloading when operating simple requests
- Impossibility to somehow manipulate the HTML code
Xafari MVC save the XAF functionality and opportunity to use all the extra modules. But it also complements them with different editors and controls.
As a result, you can create MVC based app efficiently and faster.
Like every new beginning, the start of working with ASP.NET MVC may rise some questions. And even being popular concept, MVC is still not too simple to figure out by yourself.
That is why we decided to help you in your first steps in ASP.NET MVC world immersion. We collected the top asked question about this framework, so you can check the list below, we hope you find your one here:
1. How do ASP.NET and ASP.NET MVC differ?
We can say that ASP.NET is an umbrella term as it is a platform. It has layers for web application development. ASP.NET MVC framework is one of these layers. It combines ASP.NET functionality with MVC capabilities.
2. What is ASP.NET MVC Framework?
ASP.NET MVC itself is a framework, which is a great alternative to a standard ASP.NET Web Forms. This framework allows using ASP.NET opportunities and is based on MVC concept: separates application components on independent parts (Model-View-Controller).
3. What are Model, View and Controller in MVC?
Those three elements: Model, View and Controller are the key components in ASP.NET MVC.
Model is the logic of application. It responsible for data management and cooperation with the database.
View is about user interface. It displays the required data from the model in the suitable form.
Controller is a central part of MVC. It is the first recipient of user’s request and is responsible for its processing in order to give the necessary response. Then it turns to model for the required data.
All these components are separate and can be modified without any damage to each other.
4. What are the best tutorials for learning ASP.NET MVC framework?
Among all resources, we can distinguish Top 3 as the most detailed and clear tutorials:
- ASP.NET itself. On the page ASP.NET MVC you can find information regarding your needs. There are tutorials from the very start to the latest versions with all the new changes.
- Another great source is the Microsoft Virtual Academy. On this website you will find complete video lessons with ASP.NET MVC overview, tips about building your first application and introduction to the newest MVC version. All these videos explain the topics in rather simple form so it will be understandable for both beginners and professionals.
- One more useful website is DotNetTricks. Here you can find tutorials divided on different levels: for beginners, intermediate and advanced professionals. They are all step-by-step and contain lots of useful lessons.
5. What should I know before starting with ASP.NET MVC?
The above mentioned tutorials provide the full and clear information even for the full beginners in MVC. There are only two requirements before learning:
- If would be great if you familiar with Windows programming;
- And it is also necessary to be familiar with C# basis.
6. What does separation of concerns in ASP.NET MVC mean?
Concerns separation in ASP.NET MVC is the concept, which makes the framework operate better. It means that the program is divided into separate features. Thus, it becomes easier to distinguish and solve the problem of particular component as they can be tested separately.
7. How can you explain MVC life cycle?
The MVC life cycle has two main stages: request processing and response creation. They can be described in the following steps:
- Application initialization;
- Filling the route;
- Controller creation and execution;
- Controller action invoking;
- View rendering.
8. What are the benefits of MVC?
Comparing with Web Form there are following advantages of MVC:
- Concerns separation;
- More control over HTML;
- ASP.NET features.
9. What are the Actions about in MVC?
Actions in MVC are connected with controller. They can be called methods of the controller class responsible for the view returning. They are invoked from “InvokeAction” which controller calls.
10. What are HTML helpers in ASP.NET MVC?
MVC HTML helpers can be compared with standard controls in Web Forms. But the difference is that HTML helpers do not contain a ViewState that makes them more lightweight. The main aim is to return HTML string, which can be displayed in HTML page.
As every good specialist the developer should strive to keep up with the times. Without any doubt, ASP.NET MVC is perspective, efficient framework, which will gain even more popularity in the future. And all the advantages we listed in the article prove this assumption.
We hope this article will be useful for you and it will be easier to start your first ASP.NET MVC application.