You can find my all .Net core posts here.
In this post, we will see the features of Asp .Net Core 2.1
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 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
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
- 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
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
HttpClientand implementing Polly based middleware to take advantage of that.
- Manage the lifetime of
HttpClientMessageHandlersto avoid common problems that can be hit when managing
.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
- 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 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
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:
In the future post, we will see some more .Net Core 2.1 features. Stay tuned.
Hope it helps.
8 thoughts on “ASP .Net Core 2.1 features: Part I”
The features of asp .net are explained beautifully. The portability and security are the features which contribute in the popularity of the language.
Very nice features. Good to see .NET Core evolving
Thanks a lot, Francis.