You can find my all .Net core posts here.

In this post, we will see the features of Asp .Net Core 2.1

SignalR

SignalR is coming into the .Net Core.

I have already written a post on how to use SignalR in Net Core which is here but as some of the changes are going on with SignalR, some content of the post may change in the future.

SignalR for ASP.NET Core is a rewrite of the original SignalR.

Some of the improvements are as below:

Simplified scale-out model

New JavaScript client which has no dependency on jQuery

New compact binary protocol based on MessagePack which dramatically reduces the wire size

Support for custom protocols

New streaming response model which streams the data from the server to the client

Support for clients based on bare WebSockets

HTTPS

Security is very important nowadays. Browsers are getting more and more strict for the sites that do not have HTTPS enabled.

I have already written a post on enforcing the HTTPS in the .Net Core application which is here.

As per the new announcement from .Net team, they have made HTTPS on by default and easy to configure.

HTTPS middleware is also announced by the .Net team which will redirect all HTTP traffic to HTTPS.

HSTS support has also been added to the .Net Core 2.1. This post will help to understand what is HSTS.

Rich Swagger support

I have already written a post on how to use Swagger with .Net Core which is here.

As per the new announcement, we are no more 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).

Swagger provides options for documenting the object model and customizing the UI to match your theme. Some of the highlights:



API information and the description

Data annotations

You can describe the response types

You can customize the UI and many more

More details here. https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio

IHttpClientFactory

This feature is mostly like HttpClient as a service which will handle the cross-cutting concerns like caching, retry logic, timeouts, circuit breaker etc.

Some of the benefits provided by .Net team:

Provide a central location for naming and configuring logical instances of HttpClient . For example, you may configure a GitHub client that is pre-configured to access GitHub and a default client for other purposes. Codify the concept of outgoing middleware via delegating handlers in HttpClient and implementing Polly based middleware to take advantage of that. Manage the lifetime of HttpClientMessageHandlers to avoid common problems that can be hit when managing HttpClient lifetimes yourself.

.Net Core Module

Asp .Net Core Module is the module which lets you run ASP.NET Core applications on IIS.

I have already written a post on how to host your application on IIS along with the basic details of .Net Core module which you can find here.

Today(without .Net Core 2.1) when IIS receives the request, it fires up the .Net process which will host your application which has some downsides as:

The handlers are quite expensive

If startup of the application fails, it becomes very tough to diagnose the problem

To resolve these issues, .Net team is moving that mode into the in-process mode which means your application now would be hosted on IIS process which will improve the performance almost as 6x times and error handling becomes easier.

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

Some other features

Razor pages improvement

Some improvements like support for Area in Razor pages and Support for shared directory inside the Pages folder – /Pages/Shared

MVC Functional test fixture

By this, you can easily test your MVC application end to end which includes routing, filters, controllers, actions, views and pages.

This will resolve some of the issues of testing like:

Shadow copy off

Look for missing .deps files

files Set working directory correctly

Prevent assembly cross talk

Streamlines the bootstrapping of your app on the Test Server

More details here: https://github.com/aspnet/announcements/issues/275

Build time Razor

All the razor pages and views would compile as part of a build which would improve startup performance.

I have already written a post on the same which you can find here.

UI as a library

This feature was needed for a long time.

Take your razor pages and views -> build them as an assembly -> ship them as a package -> people can use them.

Packaging Razor pages and views as a reusable library. Views and pages in libraries will automatically be discovered and can be overridden by the application.

Identity UI package and scaffolder

I have already written a post on Net Core Identity which you can find here.

We know that using readymade templates, we can add Identity code into the newly created applications but if we require Identity code into an existing application then we need to write more code.

To resolve this problem, Net Core 2.1 will provide a default identity UI implementation as a library. we just need to add a Nuget package and then we can enable default identity UI in Startup class.

There will be a new scaffolder which will help us to reuse the same repetitive code of Identity. All the scaffolded identity code would be generated in an identity specific area folder so that it remains nicely separated from your application code.

New Partial Tag Helper

Currently, there are partial views renderers like Html.Partial and Html.RenderPartial etc. But there is some limitation of above renderers.

New partial tag helper will make rendering a partial straightforward and elegant. We can specify the model using model expression syntax and the partial Tag Helper will handle setting up the correct HTML field prefix for us.

For example if you have a partial view named _PartialViewTest.cshtml then you can use this into another cshtml page using Partial tag helper as below:

<partial name=“_PartialViewTest“ asp-for=“@Model[i]“ />

General Data Protection Regulation (GDPR) Compliance

Templates are updated with new privacy features.

For security like Cookie Reason when creating a cookie and middle ware that detects if non-essential reason of cookie has been granted etc

For Identity like encrypting, downloading, deleting the user data.

Webhooks

Webhooks are my favorite. If you want to know bit more about the Webhooks then look at my post here. It is an old post but it can help to get basics of Webhooks.

Webhooks are a pattern where servers can provide the notifications to the applications in a decoupled way like basically HTTP request.

With 2.1, .Net Core team is porting a subset of the ASP.NET WebHooks receivers to ASP.NET Core.

They are planning to port the following receivers:

Microsoft Azure alerts

Microsoft Azure Kudu notifications

Microsoft Dynamics CRM

Bitbucket

Dropbox

GitHub

MailChimp

Pusher

Salesforce

Slack

Stripe

Trello

WordPress

You can find more details from here: https://blogs.msdn.microsoft.com/webdev/2018/02/02/asp-net-core-2-1-roadmap/

And videos from Channel 9 here:

Part 1

https://channel9.msdn.com/Shows/On-NET/NET-Core-21-Roadmap-PT1

Part 2

https://channel9.msdn.com/Shows/On-NET/NET-Core-21-Roadmap-PT2

In the future post, we will see some more .Net Core 2.1 features. Stay tuned.

Hope it helps.