ASP.NET MVC Framework Overview

ASP.NET MVC Framework Overview

ASP.NET MVC is an open source web application framework that implements the Model-View-Controller (MVC) architectural pattern.

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main components: the model, the view, and the controller.

The Model-View-Controller (MVC)

The Model is the part of the application that handles the logic for the application data and often model objects retrieve data (and store data) from a database.

The View is the parts of the application that handles the display of the data. Most often the views are created from the model data or you can show some custom data.

The Controller is the part of the application that handles user interaction. Typically controllers read data from a view, control user input, and send the input data to the model.

The MVC separation helps you to manage complex applications and it is ideal for using the agile approach in the development life cycle. When we first started working on ASP.NET MVC projects, the first thing that we’ve noticed is how easy is to separate a business logic from the design. For example, designers can focus on the view without depending on the business logic and developers.

The MVC separation also simplifies group development. Different developers can work on the view, the controller logic, and the business logic in parallel.

ASP.NET MVC VS. ASP.NET Webforms

Switching to ASP.NET MVC from traditional ASP.NET (Web Forms) wasn’t an easy decision. We wanted to switch because we wanted to speed up the whole development process, easier combine Open Source technologies and make life easier for tester and designers.

To be honest in one point of time we wanted to switch completely to Django or Ruby, but then we decided to go for ASP.NET MVC and was the best decision for our company.

The MVC programming model is a much lighter alternative to traditional ASP.NET (Web Forms). It is a lightweight, highly testable presentation  framework, integrated with all existing ASP.NET features, such as master pages and membership-based authentication.

The view engines used in the ASP.NET MVC 3, 4, 5 and MCV 6 Frameworks are the Razor View Engine and the Web Forms view engine. Both view engines are part of the MVC 3 framework. By default, the view engine in the MVC framework uses Razor .cshtml and .vbhtml, or Web Forms .aspx pages to design the layout of the user interface pages onto which the data is composed.

Additionally, rather than the default ASP.NET Web Forms postback model, any interactions are routed to the controllers using the ASP.NET Routing mechanism.

Because ASP.NET MVC does not maintain state information by using view state, you must find other ways to manage state information, if you need it. In addition, server controls that rely on view state and postback will not work as designed in an ASP.NET MVC application. Therefore, you should not use controls such as the GridView, Repeater, and DataList controls.

The life cycle of a Web Forms page is complex, during which many events occur. These events are not supported in an ASP.NET MVC application, because the interactions between the model, view, and controller use a different life-cycle model. For more information about the MVC life-cycle model, see Understanding the MVC Application Execution Process.

ASP.NET MVC File Structure & Naming Standards

ASP.NET MVC uses a standard directory structure and file naming standards which are a very important part of MVC application development. When you create your first ASP.NET MVC project you fill find inside the root directory three different directories: Model, View and Controller.

You will also find in the root folder a Global.asax file and a web.config like a traditional ASP.NET Web Forms application.

Project Structure

  • Controller Directory - Controller CS files
  • Models Directory - Model CS files
  • Views Directory - View aspx/ascx files
  • Global.asax
  • Web.config

Features of the ASP.NET MVC Framework

The ASP.NET MVC framework provides the following features:

1. Separation of application tasks (input logic, business logic, and UI logic), testability, and test-driven development (TDD).

2. An extensible and pluggable framework. The components of the ASP.NET MVC framework are designed so that they can be easily replaced or customized. You can plug in your own view engine, URL routing policy, action-method parameter serialization, and other components. The ASP.NET MVC framework also supports the use of Dependency Injection (DI) and Inversion of Control (IOC) container models.

3. Extensive support for ASP.NET routing, which is a powerful URL-mapping component that lets you build applications that have comprehensible and searchable URLs. URLs do not have to include file-name extensions, and are designed to support URL naming patterns that work well for search engine optimization (SEO) and representational state transfer (REST) addressing.

4. Support for using the markup in existing ASP.NET page (.aspx files), user control (.ascx files), and master page (.master files) markup files as view templates. You can use existing ASP.NET features with the ASP.NET MVC framework, such as nested master pages, in-line expressions (<%= %>), declarative server controls, templates, data-binding, localization, and so on.

5. Support for existing ASP.NET features. ASP.NET MVC lets you use features such as forms authentication and Windows authentication, URL authorization, membership and roles, output and data caching, session and profile state management, health monitoring, the configuration system, and the provider architecture.

Conclusion

The MVC framework does not replace the Web Forms model; you can use either framework for Web applications. If you are starting a new project from scratch and need to implement a new logic, I highly recommend using MVC framework. From my experience the main problem for companies to switch to ASP.NET MVC is their existing framework and solutions built on top of traditional ASP.NET Web Form. But if you have enough time and resources it is a good way to go. One of the best examples is nopCommerce Team who switched completely their project to ASP.NET MVC.

If you are interested to learn more about ASP.NET MVC, I highly recommend that you visit the official ASP.NET MVC page.

Get Started Download

Posted by Ingenium Web

Ingenium Web

iNGENIUM Ltd. is an software development company from EU which delivers a full range of custom .NET, web and mobile solutions for different business to meet partner's demand.

The Power of Imagination Makes Us Infinite

Related Posts

Comments

comments powered by Disqus