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.
- Download and get started with .NET Core 2.1 Preview 1, on Windows, MacOS, and Linux:
- Visual Studio 2017 15.6 Preview 6 or later: Don’t worry. Visual Studio and Visual Studio “Preview” can be installed side-by-side on the same device. It will have no impact on your current stable VS installation.
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,
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.
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.
Click “Yes” to trust the certificate and you will get following security warning.
Click “Yes” to install the certificate. Once installed, the application will run. You should see similar to this in your browser.
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.
Let’s visit changes made to
The following code in
Configure method allows you to opt-in for new behavior/feature for MVC. You can read more here.
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.