12 January 2018
ASP.NET Core 2 is the successor to ASP.NET Core 1 and continues the theme of providing a framework for rapid creation of Web Applications making use of a wide range of features.
Clearly ASP.NET Core 2 is similar to ASP.NET Core 1 but with a number of significant developments. First let us review the key features of ASP.NET Core.
Model View Controller (MVC) architecture provides a key separation of concerns to help with testing, team working, and maintenance.
ASP.NET MVC 1 – 5 provided the MVC architecture but ASP.NET Core adds the modular aspect. Previously an ASP.NET application had all (or at least most) features wire in. This made classic ASP.NET application fairly heavyweight, even if only a small simple Web Application was required. ASP.NET Core brings modularity which means that only those feature required need to be added within the configuration of the project.
Another key aspect of ASP.NET Core is the ability to be both created and hosted on a range of platforms. The hosting can be performed not just on Windows but also Linux and Mac. Thus, for those developers and organisations preferring Linux as a hosting option, they are no longer restricted to the likes of PHP and Enterprise Java for Web Development.
Whilst MVC provides the separation of concerns which allows unit testing, many organisations had chosen to use an Inversion of Control (IoC) framework to provide Dependency Injection to ‘build’ the application at run time. There are many possible IoC frameworks available however ASP.NET Core provides a build in Dependency Injection. Thus dependency inject can be configured for start-up to ensure that the application works with the correct objects.
ASP.NET Core also supports the Task Asynchronous Pattern (TAP) for asynchronous actions. The use TAP is now encouraged for controller actions and improves responsiveness of Web Applications. Interestingly, when working with Entity Framework the tooling for creating Controllers now only supports creation of asynchronous controllers (controllers with largely asynchronous actions).
ASP.NET Core 2 now addresses the issue that some Web Forms developers felt that the MVC architecture was overkill for a simple Web Application. ASP.NET Core 1 only supported the MVC architecture. ASP.NET Core 2 introduces Razor Pages to provide the ability to create ‘pages’ without the need to create a controller. Razor pages, as the name implies, uses the familiar Razor syntax (used for Views within MVC) for the definition of the layout of the information, but without the necessity of creating a controller.
ASP.NET Core 2 also provides a simplified configuration for standard features. ASP.NET Core 1 could require a moderate amount of configuration for even a simple Web Application.
ASP.NET Core 2 provides a number of revisions to other aspects of ASP.NET Core Web Applications. These areas of revision include configuration, logging, authentication and identity.
As mentioned earlier ASP.NET Core provides hosting options. One of these options is Kestrel. Kestrel has now gained additional configuration options to allow adding constraints for client connections and request body.
ASP.NET Core has a number of security features build in and it was possible to configure the emitting of anti-forgery tokens. ASP.NET Core 2 now makes this automatic. Thus support has been enhanced to help prevent cross-site request forgery.
Subscribe to our Newsletter – Receive the latest info on Tech courses & insights Subscribe