LIVE Instructor-Led Courses
Dismiss
MVC Training : MVC is now in ASP.NET Core 1.0

5 October 2017

MVC Training : MVC is now in ASP.NET Core 1.0

MVC

The Model View Controller (MVC) architectural pattern has a long history (together with its variants) and has been used in many languages and is encompassed by a number of frameworks (Smalltalk; PHP Zend Framework; Java Swing; etc.).  ASP.NET Core 1 provides Microsoft's latest version of a MVC architecture for Web Applications.  The main benefits of MVC revolve around the seperation of concerns, namely, the separation of Models (Data - Domain objects); Views (which the 'user' sees) and Controllers (which respond to user input).  Separation of concerns has many benefits including testability; modifyability; flexibility and team working.

Whilst there have been many previous versions of ASP.NET MVC (1, 2,..., 5) the version in ASP.NET Core 1 now has many significant new features.  Amongst these is integrated support for Dependency Injection (DI) and Inversion Of Control (IOC).  Whilst previous version of MVC could use Dependency Injection, this would require installing and configuring an IOC container.  The integration of DI and IOC support now makes use of Dependency Injection much simpler and thus testing with mocks straightforward.

WebForms vs ASP.NET MVC

Microsofts .NET has provided the ability to create Web Applications since 2002 in the form of WebForms.  WebForms has be used by many organisations for Web Sites both large and small.  However, whilst WebForms has served many organisations well, it does have a number of weaknesses.  WebForms is file based (.aspx) and has an 'interesting' page lifecycle which can potentially introduce confusing behaviour and potentially make debugging tricky.

ASP.NET MVC has evolved rapidly over its relatively short lifetime, but the underlying Model View Controller (MVC) architecture has remained the same.  The separation of concerns provided by MVC allows testing to be performed in a much easier way than with WebForms.  Essentially Unit Testing with the use of Mocks can be used with MVC Web Applications.  ASP.NET MVC affords many additional benefits over WebForms Web Applications as its more 'modular' approach also helps team working and isolation of functionality.

If a new .NET Web Application is needed then there should not be any contest as to which approach to use and MVC is definitely the way to go.  On the other hand if an organisation already has an existing WebForms application, unless it needs a rewrite the application can continue to be supported and enhanced.  However, many benefits could be gained by creating a new (replacement) application using MVC including, maintainability, testability, flexibility, team working and efficiency.  Whilst there would potentially be a lot of work involved in a rewrite, if an existing WebForms application already made use of domain models for its data and/or a separate data access layer, then there is a good chance some of this could be reused.

For those familiar WebForms wondering if they can do 'everything' with MVC that they could do with WebForms, 'mostly' yes!  Some of these features are illustrated below:

WebForms        MVC 'equivalent'
ASPX page        Controller Action with View
User Control        ViewComponent with Partial View
Server Control        HTML/Tag Helpers or Partial View
Master Page        Layout View
Error Page        Error View
Module            Filter

ASP.NET Core 1 takes MVC further, with support for multiple platforms (Windows, Linux and iOS); 'middleware'; integrated Dependency Injection (making testing even easier) and merging of Web API (REST services).  Whilst the core architecture is the same, namely MVC, there are many subtle and not so subtle differences from earlier versions of ASP.NET MVC.

MVC (in one of its forms) is certainly the way forward and ASP.NET Core 1 has improved on previous version of ASP.NET MVC.  

JBI can help keep your Developers up to date specifically with MVC training, as well as more widely as you can see by browsing our range of Microsoft Visual Studio and .NET training courses

Receive New Insights by email

 

For more more information about our range of courses: 

     - Python for Data Scientists Course

     - Agile Training Course

     - Python Advanced Training

About the author: Craig Hartzel
Craig is a self-confessed geek who loves to play with and write about technology. Craig's especially interested in systems relating to e-commerce, automation, AI and Analytics.

CONTACT
+44 (0)20 8446 7555

[email protected]

SHARE

 

Copyright © 2023 JBI Training. All Rights Reserved.
JB International Training Ltd  -  Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS

Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us

POPULAR

Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course