ASP.NET MVC Tutorials : Introduction

Beginner

2019-04-10

What is ASP.NET MVC ?

ASP.NET MVC is a web development framework developed by Microsoft on the .NET framework technologies. It utilizes the effectiveness of the Model-View-Controller (MVC) architecture to achieve higher productivity level and more modularity level.

 

It’s an alternative to additional ASP.NET Web Forms In this article we will learn why Microsoft created ASP.NET MVC and how it compares to its predecessors and alternatives.

 

History of ASP.NET MVC

 

ASP.NET Web Forms

In an attempt from Microsoft to have the Windows desktop developers to smoothly make a transition into the new world of web applications, Microsoft introduced ASP.NET Web Forms, the idea was to make Web development feel just the same as Windows Forms development by modeling the user interface as a hierarchy of server-side control objects. Each control kept track of its own state across requests using ( View State -we will talk about this later- ) rendering itself as HTML when needed and automatically connecting to client-server-side events. In a glance, It’s an event-driven graphical user interface over the web.

 

What is wrong with ASP.NET Web Forms

ASP.NET Web Forms are great but can get complicated really easily

  • View State weight : View State is an encoded hidden input string that is being passed through client-server and vice versa to help maintain the inputs state and track changes happen to them. It can result in large blocks of data being transferred between the client and server, it goes back and forth with every request, leading to slower response time and increased bandwidth demands
  • Page Life Cycle : the mechanism for event handling code, can be extraordinarily complicated, you can easily get View State errors or finding fail executions for event handlers when trying to manipulate the control hierarchy at run time.
  • Limited control over HTML : earlier releases HTML output failed to meet web development standards or make a good use of CSS through complex generated ID attribute value
  • Leaky abstraction : while Web forms tries to hide HTML and HTTP whenever possible, you will find yourself overriding the behavior of post-back event mechanism when implementing custom behaviors
  • Low testability : this tightly coupled architecture isn’t well suited for unity testing and automation testing. Integration testing can be a challenging too.

Web forms enables you to have web application up and running in no time, but if you are not careful

 

Today’s web development needs have changed with a lot of emerging technologies and new mechanisms and architectures, along with the RESTful technologies to support abstraction and provide a unified API for both mobile and web platforms through resources and HTTP actions standards, Web Forms are not best suited now for web development needs.

 

Benefits Using MVC Architecture

 

User interaction with an MVC application follows a natural cycle: the user takes an action, and in response the application changes its data model and delivers an updated view to the user. And then the cycle repeats. This is a convenient fit for Web applications delivered as a series of HTTP requests and responses.

 

Web applications necessitate combining several technologies (databases, HTML, and executable code, for example), usually split into a set of tiers or layers. The patterns that arise from these combinations map naturally onto the concepts in MVC.

 

The ASP.NET MVC Framework implements the MVC pattern and, in doing so, provides greatly improved separation of Concerns.

  • Extensibility
    • The MVC Framework is built as a series of independent components that satisfy a .NET interface or that are built on an abstract base class. You can easily replace components, such as the routing system, the view engine, and the controller factory, with a different one of your own implementation.

 

  • Tight Control
    • ASP.NET MVC works in tune with HTTP. You have control over the requests passing between the browser and server, so you can fine-tune your user experience as much as you like. AJAX is made easy, though there aren’t any automatic post-backs to interfere with client-side state.
    • If you want to use some ready-made widgets like date picker ASP.NET MVC makes it easy to integrate with these modules.It’s design for modularity.
    • ASP.NET MVC–generated pages don’t contain any View State data, so they are smaller than typical pages from ASP.NET Web Forms. It gives an enormously improved end-user experience and helps reduce the cost of running a popular web application.
  • Routing System
    • Clean URLs were hard to implement in earlier frameworks, but ASP.NET MVC uses a feature known as URL routing to provide clean URLs by default. This gives you control over your URL schema and its relationship to your application, offering you the freedom to create a pattern of URLs that is meaningful and useful to your users, without the need to conform to a predefined pattern. And, of course, this means you can easily define a modern REST-style URL schema if you wish.
  • ASP.NET MVC is Open Source
    • Unlike previous Microsoft Web development platforms, you are free to download the original source code for ASP.NET MVC, and even modify and compile your own version of it.
    • If do not like the way something works, if you find a bug, or if you just want to access something that’s otherwise inaccessible, because you can simply change it yourself.

Model View Controller

Resources