Published: 30 May 2018
7 Top features to build better applications with ASP.NET Core 2.0

Developers constantly willing for the open source platform and cross-platform for building the applications for mobile, desktop or web without the constraints. Yes ASP.NET is now ASP.NET Core offering the best of the favorable features for developers, and with updates now it is to ASP.NET Core 2.0.

Back in August, Microsoft announced a newer version of .NET Core along with ASP.NET Core named it ASP.NET Core 2.0. It is a package of amazing and outstanding features and functionalities that have boosted the performance by 20% and even raise the productivity. This results in letting the application be more reliable and robust.

Please note the prerequisites pointers – Visual Studio 2017 version 15.3 can be used to create the application based on ASP.NET Core 2.0 and even .NET Core SDK 2.0 can be downloaded for feasibility.

Let’s start exploring top 7 features of ASP.NET Core 2.0 –

1. Minimum Code

For an ASP.NET developer, smarter is to achieve the task by writing few lines of code for any of the module. By using ASP.NET Core earlier version, it was in need to set up web server – Kestrel, current directory, and if IIS is required then that too in the Main method. But with ASP.NET Core 2.0 this setup can be handled in CreateDefaultBuilder method automatically. Program.cs class has the minimum lines of code now with this version.

Code Comparison –

ASP.Net Core 1:

public class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup()
                .CaptureStartupErrors(true)
                .UseSetting("detailedErrors", "true")
                .Build();
 
            host.Run();
        }
    }

ASP.Net Core 2:

public class Program
    {
        public static void Main(string[] args)
        {
            var logger = NLog.LogManager.GetCurrentClassLogger();
            BuildWebHost(args).Run();
        }
 
        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
            .UseStartup()
            .ConfigureLogging(logging =>
            {
                logging.ClearProviders();
                logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
 
            })
            .UseDefaultServiceProvider(options => options.ValidateScopes = false)
            .Build();
    }

2. SPA Template

Angular 4, React.js and Knockout.js with Redux are no more the unaware terminologies, for better performance and flexibility, these are commonly used now. ASP.NET Core 2.0 SPA template is the sum up of all of them, where Angular 4 and React are executed in all the required pages. By using NPM, all the needed packages are automatically installed. No more to worry about installing the angular and typescript, as the packages are installed in the ready-made project, just to kick start from the coding.

3. csproj Project Files

A considerably notable big difference is with the project files. The older xproj project is now replaced with csproj. Instead of traditional csproject, Visual Studio was using xproj and project.json files, the updated file format is pretty simpler now by utilizing .NET tools like MSBuild.

4. Razor View Engine with Roslyn and Razor Pages

With Razor pages to create the dynamic pages for the web application is now possible. Rather it is more amenable as it caters features like Layout Pages, Partials Pages, Tad Helpers, Templates, code-behind page, directive etc. Although it does not follow the MVC standard pattern now and nor even uses the controller for view [.cshtml page]. Roslyn compilers and C# 7.1 features are now supported with ASP.NET Core 2.0 along with Razor View Engine .

5. Visual Basic for .NET Core

Visual Basic is now the part of .NET Core with the release of the newer version. With the deprecation of project.json, to perform the multi-targeting of frameworks and Visual Studio Ul, it has absolutely changed in Visual Studio 2017. One framework can be comfortably targeted within the project properties.

6. Expanded OS Support, Meta Packages and Runtime Store

The biggest goal of portability of .NET Core across various operating systems, desktops, servers and mobile has been fulfilled with the continuous Microsoft community support. Now Linux, Windows and macOS is treated as an individual Operating System.

asp dot net solution explorer

By expanding the reference section, all the relevant packages are already referred to the meta package. This can be clearly be seen in the attached screenshot.

asp dot net solution explorer 2

7. Expanded APIs and Ability to Reference Full Framework Libraries

The set of APIs has now broadened the scope by including almost all the missing ones. More than 32000 APIs are now supported, which makes easier to port the code to the standard library without the major modifications in the code. Also, the problem of compatibility with third-party libraries is resolved with the new compatibility shim added to enable the full framework library reference,

Microsoft team while the announcement indicated that – “Of course, this will only work for cases where the .NET Framework library uses APIs that are available for .NET Standard. That’s why this isn’t the preferred way of building libraries you intend to use across different .NET platforms. However, this compatibility shim provides a bridge that enables you to convert your libraries to .NET Standard without having to give up referencing existing libraries that haven’t been converted yet.”

Output of .Net Core 2.0

By using ASP.NET development Core Web Server option, it is easier to trace the application, as it shows how the application got started and got further rendered on the browser. Right from start to execution, each phase of information is clearly depicted here.

asp dot net core 2.0 output

Comments

  • Leave a message...

Related Articles

Software Development using Microsoft Technologies

Software Development using Microsoft Technologies

20 February 2017

Developing software using Microsoft technologies is still very relevant despite the failures of some of its technologies....

The demand for Microsoft .Net Development Today

The demand for Microsoft .Net Development Today

6 February 2017

Software development companies as well as individual developers develop apps for both software and the web using the .NET...

Microsoft .NET framework powers Enterprise Systems worldwide

Microsoft .NET framework powers Enterprise Systems worldwide

17 August 2016

The .NET framework powers numerous enterprise applications worldwide, like government, transit, hospital systems, flow of...