Skip to main content

A Quick first look at ASP.NET Core 2.1

Earlier I posted about new features of .NET Core 2.1 and a quick summary of what’s new in ASP.NET Core 2.1, Yesterday ASP.NET Core 2.1 preview was released and available for everyone to play with. So I installed it and here is a quick first look at ASP.NET Core 2.1 preview-1 release. In this post, only a few new features are covered.

A Quick first look at ASP.NET Core 2.1

To use .NET Core 2.1 preview, following installation is required.

The installation will take some time to install. Once both the installations are finished, open Visual Studio “Preview” version, hit Ctrl+Shift+N and select the ASP.NET Core Web Application (.NET Core) project type from the templates. When you click Ok, you should be prompted with the following,

ASP.NET Core 2.1 Version Selector

As you can see, both the versions are listed in the dropdown. Select ASP.NET Core 2.1 and choose either Web Application or Web Application(MVC). The Web Application template will create an ASP.NET Core Razor pages based application. Hit Ok and let Visual Studio restores the packages.

ASP.NET Core 2.1 introduces a new meta-package for use by applications: Microsoft.AspNetCore.App. So the new projects created that target 2.1 will use this meta-package by default, rather than the existing meta-package Microsoft.AspNetCore.All. You can verify it in dependencies -> SDK section.

ASP.NET Core 2.1 new meta package

The new meta-package differs from the existing meta-package in that it reduces the number of dependencies of packages not owned or supported by the ASP.NET or .NET teams. Read more here.

Now, build the application and run it. You will be prompted with SSL warning. As by default, ASP.NET Core 2.1 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.

SSL Warning

Click “Yes” to trust the certificate and you will get following security warning.

SSL Certificate Installation

Click “Yes” to install the certificate. Once installed, the application will run. You should see similar to this in your browser.

GDRP Compliance Pop up

If you didn’t trust the ASP.NET Core development certificate, then the browser will display a security warning. There are two things to notice here. The site is running on HTTPS protocol and a pop-up UI to ask for (and track) consent from your users for storing personal information. This is to meet General Data Protection Regulation (GDPR) Compliance. You can see two new files added to your default template responsible for the UI and consent.

ASP.NET Core 2.1 Application Structure

Let’s visit changes made to Startup.cs.

ASP.NET Core 2.1 Startup changes

The following code in Configure method allows you to opt-in for new behavior/feature for MVC. You can read more here.

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

That’s it for now. There are many new features introduced in ASP.NET Core 2.1, so it’s time to play a lot more with .NET Core 2.1. Keep visiting for more.

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

4 thoughts on “A Quick first look at ASP.NET Core 2.1

  1. If you are considering future articles: I am most interested in the upgrade process for existing .net core 2.0 asp.net webapi and ef core projects.

Leave a Reply

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