ASP.NET Core Real Power: Features And Benefits

Microsoft has introduced ASP.NET Core with a lot of new features and many more enhancements in existing ASP.NET technology. In this article I will explain briefly about all those features and enhancements of ASP.NET Core which are the real power of ASP.NET Core.

  1. Power of Roslyn (.NET Compiler Platform): Roslyn is an open-source .NET Compiler platform which can be used to build the source code of C# and Visual Basic. Roslyn provides rich code analysis APIs. We can use this API to build code analysis tool. The same API also used by Microsoft.

    Apart from Code Analysis API Roslyn also provides feature of Syntax Visualizer and many more interesting feature.

    Roslyn SDK (.NET Compiler Platform SDK) can be downloaded from here and also from GitHub.

  2. Open Source: ASP.NET Core is open source and available on GitHub.

  3. Platform Independent (Cross Platform Support): ASP.NET Core is supported on Windows, Mac and Linux OSX.

    Platform Independent

  4. Built from scratch: ASP.NET Core is not like an enhancement to ASP.NET 4.5 but it has been built from scratch. A lot of new features have been added to it and some of the existing features has been dropped also. To support Cross Platform and improve performance some existing features have been removed.

  5. DNVM (.NET Version Manager): DNVM is a command line tool which provides the functionality for configuring .NET runtime.

    DNVM

  6. NET Execution Environment (DNX): DNX is an SDK (Software Development Kit) and runtime environment that has everything we need to build and run across platform ASP.NET Core application. It can run on Windows, Mac, and Linux and provides a lot of features like managing entry point CLR hosting. DNX support web and console application on Windows, Mac, and Linux.

    DNX

  7. DNU (.NET Development Utility): DNU is a command line tool which is used for managing packages (uses Nuget behind the scene) and building (compiling) the application. We use different types of commands like "dnu restore” & "dnu build”

    DNU

  8. Yeoman Marvellous ASP.NET Core generator:

    Yeoman

    Yeoman is a scaffolding tool for generating types of ASP.NET Core application. When it runs you will find that it is writing ASP.NET 5 instead of ASP.NET Core because ASP.NET 5 has been renamed to ASP.NET Core but yeoman is not updated after that.

    Using Yeoman we can create different types of ASP.NET Core applications like:

    1. Empty Application
    2. Console Application
    3. Web Application
    4. Web Application Basic [without Membership and Authorization]
    5. Web API Application
    6. Nancy ASP.NET Application
    7. Class Library
    8. Unit test project

    Class Library

    Unit test project

    To learn more about yeoman you can visit the link.

  9. HTTP/2 Support

    HTTP/2 is a new version of HTTP protocol, faster than http 1.1. HTTP/2 is binary instead of textual, fully multiplexed instead of blocking, and allows the server to "push” responses proactively into client caches. It also provides the feature of parallelism and header compression which improves website performance drastically.

    To know more about HTTP/2 support you can go through the article: Creating HTTP/2 Supported Website With ASP.NET Core and Hosting In Windows 10 (IIS 10.0.x).

  10. Visual Studio Code for cross platform support and other Editors: All of us are aware of Microsoft Visual 2015 Editor. But Microsoft Visual 2015 is only supported in windows so Microsoft introduced another cross platform Editor known as Visual Studio Code Editor. This Editor can be installed in Windows, Mac and Linux OSX. Apart from this we can develop ASP.NET Core application using Vim, Sublimer, Atom, etc.

    cross platform

  11. New Project System (File System) and Background Compilation: ASP.NET Core works on new project system in which everything is based onthe  file system. It uses the power of Roslyn and source code is compiled in background automatically and we do not need to build the application to see the output. We just need to refresh the browser. If I add an index action or add a readme.html file we need to pass the valid URL and refresh the browser only and we will get the output from latest build.

    When we create ASP.NET Core application using Yeoman generator it says that dnu build is optional.

    dnu build

    For more details about background compilation, File System and Multiple Editors support you can go through the article: ASP.NET Core: File System, Background Compilation, and Editors.

  12. Support for Grunt:

    Grunt

    Grunt is a JavaScript task runner used for automate script Minification, CSS pre-processors, TypeScript compilation, etc. it is fully supported in ASP.NET Core.

    To learn more about grunt you can visit the link.

  13. Support for Gulp:

    Gulp

    Gulp is supported in ASP.NET Core. It is a JavaScript-based streaming build toolkit for client-side code. When we create an ASP.NET Core web application then it creates a file gulpfile.js. Below is the sample code for gulpfile.js.
    1. /// <binding Clean='clean' />  
    2. "use strict";  
    3. var gulp = require("gulp"),  
    4.     rimraf = require("rimraf"),  
    5.     concat = require("gulp-concat"),  
    6.     cssmin = require("gulp-cssmin"),  
    7.     uglify = require("gulp-uglify"),  
    8.     project = require("./project.json");  
    9.   
    10. var paths = {  
    11.     webroot: "./wwwroot/"  
    12. };  
    13.   
    14. paths.js = paths.webroot + "js/**/*.js";  
    15. paths.minJs = paths.webroot + "js/**/*.min.js";  
    16. paths.css = paths.webroot + "css/**/*.css";  
    17. paths.minCss = paths.webroot + "css/**/*.min.css";  
    18. paths.concatJsDest = paths.webroot + "js/site.min.js";  
    19. paths.concatCssDest = paths.webroot + "css/site.min.css";  
    20.   
    21. gulp.task("clean:js", function(cb)  
    22. {  
    23.     rimraf(paths.concatJsDest, cb);  
    24. });  
    25.   
    26. gulp.task("clean:css", function(cb)  
    27. {  
    28.     rimraf(paths.concatCssDest, cb);  
    29. });  
    30.   
    31. gulp.task("clean", ["clean:js""clean:css"]);  
    32.   
    33. gulp.task("min:js", function()  
    34. {  
    35.     gulp.src([paths.js, "!" + paths.minJs],  
    36.         {  
    37.             base"."  
    38.         })  
    39.         .pipe(concat(paths.concatJsDest))  
    40.         .pipe(uglify())  
    41.         .pipe(gulp.dest("."));  
    42. });  
    43.   
    44. gulp.task("min:css", function()  
    45. {  
    46.     gulp.src([paths.css, "!" + paths.minCss])  
    47.         .pipe(concat(paths.concatCssDest))  
    48.         .pipe(cssmin())  
    49.         .pipe(gulp.dest("."));  
    50. });  
    51.   
    52. gulp.task("min", ["min:js""min:css"]);  
    To learn more about gulp you can visit the link.

  14. Support for Bower :

    Support for Bower

    Bower is a package manager for the web. When we create a new ASP.NET Core application then a file with name "bower.json” is created.

    Sample code for"bower.json” is:
    1. {  
    2.     "name""Webapp5",  
    3.     "private"true,  
    4.     "dependencies":  
    5.     {  
    6.         "bootstrap""3.3.5",  
    7.         "jquery""2.1.4",  
    8.         "jquery-validation""1.14.0",  
    9.         "jquery-validation-unobtrusive""3.2.4"  
    10.     }  
    11. }  
    To learn more about bower you can visit the link.

  15. Support for NPM: In ASP.NET Core we can use NPM for managing client-side dependencies.

    To learn more about NPM you can visit the link.

  16. Cloud Optimized Core CLR: The .NET Core Framework is optimized for the cloud. It is a cross platform framework for building ASP.NET Core applications. It is supported in Windows, Mac and Linux and open source on GitHub. It contains a set of libraries "CoreFX” and optimized runtime"CoreCLR”.

  17. Optimized framework: Framework has been optimized by removing "System.web” dll file which was expensive and web pages were loaded slowly.

  18. Multiple Framework Support: ASP.NET Core has support for three different types of frameworks which are:

    1. .NET Framework (.NET Framework 4.6 & .NET Framework 4.6.1)
    2. .NET Core 1.0 and
    3. Mono

    NET Framework (.NET Native Framework)

    The .NET Framework is the most popular, well-known framework for developing ASP.NET Core applications  which provides the highest level of compatibility. It is stable and tested framework being used for the last 15 years. But if you are looking for cross platform support then you should go for .NET Core 1.0 and looking only for Linux go with Mono because .NET native Framework is only supported in Windows.

    .NET Core Framework

    .NET Core 1.0 (earlier known as .NET Core 5) is a cross platform supported framework for building ASP.NET Core applications. It is supported in Windows, Mac, and Linux and is open source on GitHub. It contains a set of libraries "CoreFX” and optimized runtime"CoreCLR”.

    Mono Framework

    Mono is open source & cross-platform .NET framework built primarily for non-Windows platforms. Mono is not supported by Microsoft but it can be used for building ASP.NET core application on Linux because it is more stable than .NET Core 1.0.

  19. ASP.NET Core on Nano Server: Nano Server is a remotely administered server operating system optimized for private clouds and data centers. 

  20. Support for OmniSharp:

    OmniSharp

    We can use OmniSharp with ASP.NET Core for cross platform .NET development.

  21. Use C# 6 featuresfor ASP.NET Core Development: We can get the benefits of C# 6 language feature in ASP.NET Core. We can use the following features of C# 6.0 with ASP.NET Core:

    NULL Conditional Operator, Expression-bodied members, Expression-Bodied Properties, Expression-Bodied Methods, Using types instead of namespaces as directive, Using enum in using block as directive, Using static classes as directive, Using non-static classes in using block as directive, Index Initializers in C# 6, Getter-Only & Auto Properties Initializers in C# 6, nameof operator, Exception filters, Await in catch/finally blocks, string interpolation, etc.

  22. Introducing new HTTP pipeline in ASP.NET Core: ASP.NET Core provides the facility to host the application on different types of servers; i.e, it can be hosted on OWIN based server, IIS, self-hosting (hosting in your own process).

  23. Benefits of DI & IOC: Built-in Dependency Injection (DI) for MVC, SignalR, Identity & Web API and replace built-in Inversion of Control (IOC) container with our choice of container.

  24. Power of.NET Framework 4.6: Robust, Modular, stable, familiar & most popular framework having more than 15 years of supporting experience for micro level to enterprise level products & projects.

  25. Unified MVC and Web API Controllers &Power of Entity Framework

  26. Dotnet CLI for RC2: Earlier K Project has been introduced which includes KRE (K Runtime Environment) & KPM (K package Manager) but later on Microsoft introduced DNVM, DNX and DNU. Now Microsoft has planned to replace DNVM, DNX and DNU with Dotnet CLI.

So currently we are using commands like "dnu restore”,"dnu build” & "dnx web” but in next release RC2 we can use the command like "dotnet new”, "dotnet restore”, "dotnet run” etc. But we have to wait for the official release of RC2 for the complete details of commands and scaffolding tools.

.NET Command Line Interface (CLI) is a tool used for building .NET Core application and libraries. We can download and install CLI from the path. For Mac and Linux installation you can visit the link. I am installing it for Windows but you can install it for Linux and Mac as well. After downloading the .exe file for windows execute the .exe file and install it.

You can learn more about ASP.NET Core from these articles: