As per Microsoft, .NET can now be described in one line and that is as follows.
Free. Cross-Platform. Open Source. A developer platform for building all your apps.
Great, this is absolutely right. .NET is now .NET Core and known as a cross-platform and open-source platform where you can build all types of applications. An application could be a web app, desktop app, mobile app, or gaming app. All types of apps can be created using a single platform and it’s none other than .NET Core.
Recently, Microsoft announced a new version of ASP.NET Core along with .NET Core and that is ASP.NET Core 2.0 which has new and amazing features which not only improve performance but also increase productivity and make your application more robust and reliable. I am very excited to share features of ASP.NET Core 2.0.
You can use ASP.NET Core 2.0 with Visual Studio 2017 version 15.3. You can download .NET Core SDK 2.0 to take advantage of these features. Asp.NET Core 2.0 has come up with some new features. So, let’s start to understand not all but the top 10 features of ASP.NET Core 2.0.
Performance
It is now much faster than ASP.NET Core 1. x. It is now more than 20% faster than the previous version. You can check it out now with techempower.com as the following URL shows. Just search aspnetcore on this URL, and you will get the result.
https://www.techempower.com/benchmarks/previews/round15/r14-vs-r15p3.html
Minimum Code
We need to write a few lines of code to achieve the same task. For example, authentication is now easy with a minimum line of code. When we talk about the Program.cs class, ASP.NET Core 2.0 has the minimum line of code in the Main method as compared to the previous version. With an earlier version of ASP.NET Core, we need to set up everything in the Main method like your web server “Kestrel”, your current directory. If you would like to use IIS, then you need to integrate IIS as well. But with ASP.NET Core 2.0, we don’t need to take care of these things; these will be handled by the CreateDefaultBuilder method automatically to set up everything.
Razor Page
ASP.NETCore 2.0 has introduced Razor Page to create dynamic pages in a web application. Using Razor Pages, we can create a simple and robust application using Razor features like Layout Pages, Tag Helpers, Partials Pages, Templates and ASP.NET features like the code behind pages, directives, etc. Razor Page does follow the standard MVC pattern. Here we use different types of directives like @page, @model, @namespace, @using, etc. on the view page and the respective code behind the page inherited with the PageModel class which is the base class.
Razor page is simply a view with an associated code-behind class that inherits the Page Model class which is an abstract class in “Microsoft.AspNetCore.Mvc.RazorPages“. It doesn’t use a controller for view [.cshtml page] as we do in MVC but the code behind works like a controller itself. These pages [.cshtml] are not placed inside the Pages folder.
Choose Web Application as a template when you would like to create a Razor Pages application in Asp.NET Core 2.0.
Meta Packages and Runtime Store
ASP.NETCore 2.0 comes with the “Microsoft.AspNetCore.All” package which is nothing but a meta package for all dependencies that are required when creating ASP.NET Core 2.0 applications. It means once you include this, you don’t need to include any other packages or don’t need to depend on any other packages. It is because “Microsoft.AspNetCore.All” supports .NET Runtime Core Store which contains all the runtime packages which are required for ASP.NET Core development.
Here, you can see only one reference is added and that is “Microsoft.AspNetCore.All” with version 2.0.5. So, this meta package will take care of all other packages required at runtime using the Runtime Store.
You don’t need to add any other packages from outside; all are here with the meta package and you don’t need to take care of multiple packages with a different version, here you only have one version, 2.0.5 or 2. x.x.
When you expand this reference section, you will find all the related packages are already referred to this meta package as the following image shows.
.NETStandard 2.0
The .NET Standard is a group of APIs that are supported by the .NET Framework. As compared to the previous version of .NET Standard 2.0 supports dubbed APIs in numbers. More than 3200+ APIs are supported by .NET Standard 2.0.
Leave the exception cases but .NET Standard 2.0 supports 70% of APIs which are being used or can be used with .NET Framework.
Just for example, .NET Standard didn’t support the Logging feature using Log4Net, so we are not able to use it with Asp.NET Core, but with.NET Standard 2.0, this is in. We can now use lots of features that are part of .NET Framework but we were not using it in ASP.NET Core with .NET Standard 1. x. We can use .NET Framework along with .NET Standard 2.0.
So, now going forward we can use all related APIs with .NET Standard 2.0.
For more details, read the following article.
https://docs.microsoft.com/en-us/dotnet/standard/whats-new/whats-new-in-dotnet-standard?tabs=csharp
SPA Template
ASP.NETCore 2.0 comes with a new SPA template which can be used with the latest version of Angular 4, React.js, and Knockout.js with Redux. By default, Angular 4 is implemented with all required pages and React is also the same. When we create an application using the SPA template all required packages will automatically be installed using NPM packages. You don’t need to take care of angular packages or typescript packages, it will install and give a ready-made project from where you can start your coding.
sys
The packages “Microsoft.AspNetCore.Server.WebListener” and “Microsoft.NET.Http.Server” are now merged into one package and that package is Microsoft.AspNetCore.Server.HttpSys. Respective of this, the namespace is also updated to implement Microsoft.AspNetCore.Server.HttpSys. So, from now on, rather than implementing two packages, we only need to implement one.
Razor View Engine with Roslyn
ASP.NET Core 2.0 is now supported by the Roslyn compiler and supports C# 7.1 features. So, now, we can get the benefit of the Roslyn compiler in the ASP.NET Core MVC application with Razor View Engine.
Visual Basic Support
With this new release of .NET Core 2.0, Visual Basic is part of the .NET Core programming language. Now we can create a different type of application using Visual Basic code as well.
Output from ASP.NET Core Web Server
In the output window, now we can trace our application using the “ASP.NET Core Web Server” option. This will show you how our application is started and rendered on the browser. So, each piece of information from starting to rendering will get you here.
Conclusion
So, today, we have learned about the top 10 features of ASP.NET Core 2.0.
I hope this post will help you. Please put your feedback using comments which helps me to improve myself for the next post. If you have any doubts please ask your doubts or query in the comment section and if you like this post, please share it with your friends. Thanks.