Skip to main content
Quick summary of what’s new in ASP.NET Core 2.1

Quick summary of what’s new in ASP.NET Core 2.1

Earlier I posted about new features of .NET Core 2.1 having screenshots and video links from the official announcement. Now it’s time to look into things in more detail and with a little explanation to understand things better. Therefore, in this post, find a short and quick summary of what’s new in ASP.NET Core 2.1.

Quick summary of what’s new in ASP.NET Core 2.1

  • SignalR is a framework for doing real-time web development like connected clients or chat application. Till today, an official version of the SignalR framework is not available for ASP.NET Core. Finally, SignalR is coming to ASP.NET Core. SignalR for ASP.NET Core is a rewrite of the original SignalR and comes with some improvements.
    • It has a brand-new JavaScript client written in TypeScript and no longer depends on jQuery.
    • It offers two built-in hub protocols – a text protocol based on JSON and a binary protocol based on MessagePack.
    • Support for Custom Protocols
    • Improved and simplified scale-out model.
    • Sticky sessions are required due to the new scale-out model.

    Read this post more details.

  • By default, ASP.NET Core app will now run on HTTPS. A developer certificate will be set up for the development environment to run HTTPS even on the local machine. To implement this, a new middleware UseHttpsRedirection is introduced to redirect all HTTP traffic to HTTPS. The support for HSTS protocol is also added to enforce clients (web browsers or other complying user agents) to interact with the server via HTTPS connections, and never via the HTTP protocol. The new default template will have these middlewares added to the Configure method.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            // Configure developer middlewares
        }
        else
        {
            app.UseHSTS();
        }
        app.UseHttpsRedirection();
    }
    

    HSTS protocol is typically used in non-development scenarios, therefore the UseHSTS() middleware is added in the else part of the code. This change will help to fix HTTPS specific issues reproduced in the production environment.

  • New Web API conventions for rich Swagger support. Today, you have to use different attributes for detailed swagger document experience. ASP.NET Core 2.1 will provide rich swagger documentation out of the box and no longer required to write different attributes to write swagger documentation of an API.

    The .Net team has added an opinionated layer that infers the possible responses based on what you’re likely to have done with your actions (you can still use attributes when you want to be explicit).

  • Today, you need to validate the model for error checking, but no longer in ASP.NET Core 2.1. The new ApiController attribute will now perform automatic model validation and automatically responds with a 400 error.
  • A new type called ActionResult<T> is introduced that allows you to return either the response type or any action result, while still indicating the response type. Like,
    public ActionResult<ToDo> Get(int id)
    {
        if (!_repository.TryGetToDo(id, out var todo))
        {
           return NotFound();
        }
        return todo;
    }
    
  • Introduction of HttpClientFactory (HttpClient as a service). The new HttpClientFactory is a central repository to register, configure and consume instances of HttpClient in your application. It fixes issues faced with the current implementation of HttpClient. Read HttpClientFactory in ASP.NET Core 2.1 (Part 1) for a detailed introduction. Also, read 3 ways to use HTTPClientFactory in ASP.NET Core 2.1
  • Improvement to ANCM for better performance. ASP.NET Core Module (ANCM) lets you run ASP.NET Core applications behind IIS. ANCM is a native IIS module that hooks into the IIS pipeline and redirects traffic to the back-end ASP.NET Core application. ASP.NET Core applications run in a process separate from the IIS worker process, ANCM also does the process management. ANCM starts the process for the ASP.NET Core application when the first request comes in and restarts it when it crashes.

    In 2.1, a new in-process mode to ANCM is added for .NET Core based apps, which loads the runtime and the app inside the IIS worker process (w3wp.exe). This removes the performance penalty of proxying requests. This will improve the performance almost as 6x times and error handling becomes easier.

    In short, The runtime and app are both would be loaded into the IIS worker process (w3wp.exe).

  • ASP.NET Identity as UI library– ASP.NET Core 2.1 provides a default identity UI implementation as a library. You can add the default identity UI to your application by installing a NuGet package and then enable it in your Startup class.
  • MVC Functional test fixture to enable better testing of MVC application end to end which includes routing, filters, controllers, actions, views, and pages. This will help to get over of current pitfalls.
  • Virtual authentication schemes to mix authentication schemes, like bearer tokens and cookie authentication in the same app.
  • ASP.NET Core 2.1 will introduce a new meta-package for use by applications: Microsoft.AspNetCore.App. The new meta-package differs from the existing meta-package because it reduces the number of dependencies of packages not owned or supported by the ASP.NET or .NET teams. More details here.
  • General Data Protection Regulation (GDPR) Compliance. The ASP.NET Core 2.1 project templates will include some extension points to help you meet some of your UE General Data Protection Regulation (GDPR) requirements. The new template will support UI to ask for (and track) consent from your users for storing personal information.
  • Today, razor pages are compiled at runtime. In ASP.NET Core 2.1, the razor pages and views would compile as part of a build process to improve startup performance. The good thing about this implementation is, it still supports the live edit/refreshing of razor pages.
  • Razor UI as a class library – ASP.NET Core 2.1 makes easier to build and include Razor based UI in a library and share it across multiple projects. A new Razor SDK will enable building Razor files into a class library project that can then be packaged into a NuGet package.
  • Razor Pages will now support areas and shared directory inside the Pages folder – /Pages/Shared to look for razor assets.
  • With ASP.NET Core 2.1, a subset of the ASP.NET WebHooks receivers are ported to ASP.NET Core. The following receivers are planned to make work on ASP.NET Core: Azure alerts, Azure Kudu notifications, Dynamics CRM, Bitbucket, Dropbox, GitHub, MailChimp, Pusher, Salesforce, Slack, Stripe, Trello, WordPress. Read WebHooks with ASP.NET Core – DropBox and GitHub to know how to use Webhooks with ASP.NET Core 2.1.

Reference Reading:

Update: ASP.NET Core 2.1 preview 1 is already out. Please read my post A quick first look at ASP.NET Core 2.1

Summary

ASP.NET Core 2.1 is more of a community and customer feedback oriented release. This release addresses the painful areas and introduces a couple of new features like HTTPS by default, rewritten version of SignalR for ASP.NET Core, razor pages improvement, faster performance etc.. At the time of writing this post, it is Preview 2 release and expected to release soon. This post talks about some of the most important newly introduced features and changes coming in ASP.NET Core 2.1. It is very unlikely that these things will change/update drastically, once the final version is out.

Thank you for reading. Keep visiting this blog and share this in your network. Please put your thoughts and feedback in the comments section.

PS: If you found this content valuable and want to return the favour, then Buy Me A Coffee

3 thoughts to “Quick summary of what’s new in ASP.NET Core 2.1”

Leave a Reply

Your email address will not be published. Required fields are marked *