All about ASP.NET Core 2.1

By Aarav Goel 27-Dec-2022
All about ASP.NET Core 2.1

Introduction

This article highlights few of the new features and concepts in ASP.NET Core 2.1

Background

The new version of ASP.NET is called ASP.NET Core and it contains the most significant architectural redesign of ASP.NET. This article will highlight the new features and concepts added in the new ASP.NET

 Enquire Now 

What is ASP.NET Core?

ASP.NET Core  2.1 is the new open-source and cross-platform framework for building modern cloud-based web apps. It has been built from the ground up to provide an optimised development framework for web apps that are either deployed to the cloud or on your local servers. Adding to that, it was redesigned to make ASP.NET leaner, modular (so you can just add features that your application requires), cross-platform (so you can easily develop and run your app on Windows, Mac or Linux, which is pretty awesome) and cloud optimised (so you can deploy and debug apps over the cloud).

Here is the list of the core significant changes in ASP.NET Core 2.1

  • MVC
  • WebAPI Improvements
  • SignalR
  • WebHooks
  • GDPR
  • Security
  • Identity

MVC

Razor Pages improvements

In 2.1, we have made a variety of improvements to Razor Pages to make it even more productive.

Razor Pages in an area

Areas provide a way to partition a large  MVC  app into smaller functional groupings, each with its own controllers and views. In 2.1, we have added support for areas to Razor Pages so that areas can have their own pages directory.

Support for /Pages/Shared

In 2.1, Razor Pages will fall back to finding Razor assets such as layouts and partials in /[pages root]/Shared before falling back to /Views/Shared.

Web API improvements

ASP.NET Core gives you a single unified framework for building both Web UI and Web APIs. In 2.1, we have made various improvements to the framework for building Web APIs.

ALSO READ: Top 10 Highest-Paying Certifications

Better Input Processing

We want the experience around invalid input to be more automatic and more consistent. More concretely, we’re going to:

  • Create a programming model where your action code isn’t called when a request has validation errors (see “Enhanced Web API controller conventions” below)
     
  • Improve the fidelity of error responses when the request body fails to deserialize or the JSON is invalid
     
  • Enable placing validation attributes directly on action parameters

Improved OpenAPI specification support

We want to embrace the OpenAPI specification (previously called “Swagger”) and make Web APIs built with ASP.NET Core more descriptive. Today you need a lot of “attribute soup” to get a reasonable OpenAPI spec from ASP.NET Core. We plan to introduce an opinionated layer that infers the possible responses based on what you’re likely to have done with your actions (attributes still win when you want to be explicit).

Enhanced Web API controller conventions and ActionResult

Use [ApiController] attribute as the way to opt-in to Web API specific conventions and behaviors. These behaviors include:

  • Automatically responding with a 400 when validation errors occur
  • Infer smarter defaults for action parameters: [FromBody] for complex types, [FromRoute] when possible, otherwise [FromQuery]
  • Requires attribute routing – actions are not accessible by convention-based routes

SignalR

For ASP.NET Core 2.1, we are porting ASP.NET SignalR to ASP.NET Core to support real-time web scenarios. As previously announced, ASP.NET Core SignalR will also include a number of improvements, including a simplified scale-out model, a new JavaScript client with no jQuery dependency, a new compact binary protocol based on MessagePack, support for custom protocols, a new streaming response model, and support for clients based on bare WebSockets.

WebHooks

WebHooks are lightweight HTTP patterns for event notifications across the web. WebHooks enable services to send event notifications over HTTP to registered subscribers. For 2.1, the following receivers are planned to work on ASP.NET Core: Azure alerts, Azure Kudu notifications,  Dynamics CRM , Bitbucket, Dropbox, GitHub, MailChimp, Pusher,  Salesforce , Slack, Stripe, Trello and  WordPress.

You May Also Like: Understanding SAP Modules: SAP FI, SAP CO, SAP SD, SAP HCM, and more

Improvements for GDPR

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 infor mation.

Security

HTTPS

With the increased focus on security and privacy, enabling HTTPS for web apps is more important than ever before. To facilitate secure website development, we are enabling HTTPS in ASP.NET Core 2.1 by default.

HTTPS redirection and enforcement

Web apps typically need to listen on both HTTP and HTTPS, but then redirect all HTTP traffic to HTTPS.       In 2.1, we are introducing specialised HTTPS redirection middleware that intelligently redirects based on the presence of configuration or bound server ports.

Identity

Identity as a library

ASP.NET Core Identity gives you a framework for setting up authentication and identity concerns for your site, including user registration, managing passwords, two-factor authentication, social logins and much more. For 2.1, we will provide a default identity UI implementation as a library.

 Enquire Now 

Associated Course

32 Hours
English
32 Hours
English
32 Hours
English
Aarav Goel

Aarav Goel has top education industry knowledge with 4 years of experience. Being a passionate blogger also does blogging on the technology niche.