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 cross-platform and open source platform where you can build your all types of applications. An application could be a web app, desktop app, mobile app or gaming app. All type 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, you will get the result.
https://www.techempower.com/benchmarks/previews/round15/r14-vs-r15p3.html
Minimum Code
We need to writea 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 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 setup 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 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 page, directive etc. Razor Page does follow the standard MVC pattern. Here we use different types of the directive like @page, @model, @namespace, @using etc. on view page and respective code behind page inherited with PageModel class which is base class.
Razor page is simply a view with associated code-behind class which inherits 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 Razor Pages application in Asp.NET Core 2.0.
Meta Packages and Runtime Store
ASP.NETCore 2.0 comes with “Microsoft.AspNetCore.All” package which is nothing but a meta package for all dependencies which are required when creating ASP.NET Core 2.0 application. 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 Runtime Store.
You don’t need to add any other packages from outside; all is here with 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 which are supported by .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 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 which 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 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 SPA template than 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 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 to 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 Roslyn compiler in 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 .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 got rendered on the browser. So, each information from starting to render 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 comment which helps me to improve myself for 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.