.NET Core is the latest general purpose development platform maintained by Microsoft. It is fast, flexible, lightweight, modular, open source and It works across different platforms where web applications and services can run on Windows, Linux and Mac. .Net core happens to be one of the major contributions by Microsoft where Developers can now build Android, iOS, Linux, Mac, and Windows applications with . dot(.) net , all in Open Source.
.NET Core is named “Core” because it includes core features of the .NET framework. The main objective of .net core is to make .net core framework open source and cross-platform compatible so it can be used in resource-constrained environments. It includes minimum features that are required to run a basic .NET Core app and other advanced features that can be included as a package from NuGet.
The following figure illustrates the components of .NET Core and their importance.
As you can see above,
Microsoft dot .net Core includes .net compiler platform Roslyn, .net core runtime CoreCLR, .net core framework CoreFX and ASP.NET Core . asp.net core is a part of .net core SDK because of that you don’t need to install asp.net core separately. asp.net core and .net core is a part of .net Foundation.
.NET Core comes under MIT or Apache 2 licenses.
Microsoft .NET Core is a better option if you:
- Are not afraid of learning and upgrading new things.
- Willing to develop apps on Windows, Linux, and Mac operating systems using .NET Core.
- Who is not scared of breaking and fixing things because .net core is not fully grown yet.
- Love working with open source applications for example Java,PHP…etc
.Net core Charactersistics will explain better that “Why .net core is good choice?”
Supports Multiple Platforms:
.NET Core applications can run on Windows, Linux and Mac. So you don’t need to build different apps for different platforms using different frameworks.
Fast:
.NET Core no longer depends on some important dll files as like .net framework For example System.Web.dll for browser-server communication. .NET Core allows us to include packages which we need for our application for example System.web.MVC. This reduces the request pipeline and improves the performance as well as the scalability.
IoC Container:
It includes built-in IoC container for automatic dependency injection which makes it maintainable and testable.
For example.
public class PaymentService: IPaymentService
{
public ILogger Logger { get; }
//automatically passes the logger factory in to the constructor via dependency injection
public PaymentService(ILoggerFactory loggerFactory)
{
Logger = loggerFactory?.CreateLogger();
if(Logger == null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}
Logger.LogInformation("PaymentService created");
}
}
Integration with Modern UI Frameworks:
It allows you to use and manage modern UI frameworks such as AngularJS, ReactJS, Umber, Bootstrap etc. using Bower (a package manager for the web).
Hosting:
.NET Core web application can be hosted on multiple platforms with any web server such as IIS, Apache etc. It is not dependent only on IIS as a standard .NET Framework.
Compatible:
.net core is compatible with .Net framework, Xamarin and Mono, via the .NET Standard Library
Support Cloud Environment:
With the help of .Net core, you can develop a cloud base application like Mobile back-end, Internet of things app, web application etc.
Middleware:
This middleware is a Key feature of .Net core How application performs on HTTP Request. Middleware also Control our application when to display error, when to authenticate a user and also middleware used to define application types like a simple static website with Html page or MVC application. In Asp.Net Core the request delegate handles each HTTP request using Middleware.
Command Line Application (dotnet.exe):
.Net core also provides command line support for all Platform, like in Windows, Mac and Linux you can use a command line for creating a new application, execute an application, host application. Followings are commands to create, deploy and run a new application on the .net core.$dotenet new
$dotenet restore
$dotenet build
$dotenet run
Most Effective Use of Library:
.Net core support nugget packages for all logical library, so Instead of loading whole library you just need to load require a portion of the library. Like Microsoft.Web.MVC Consist of Microsoft.Web.MVC.Controls,
Microsoft.Web.MVC.ExpressionUtil,
Microsoft.Web.MVC.Internal etc.
Which Loaded every time in memory regardless of your project need or not need. With .net code, we reference load only required components for a project that way it’s optimized and create a lightweight application.
High performance:
Some say that performance is a critical feature of your software. I tend to agree! With the introduction of .NET Core and the Kestrel web server, .NET is touted as one of the fastest web application frameworks available. TechEmpower has some cool benchmarks you can check out.
The technology that powered the .NET integrated pipeline and IIS was roughly 15 years old. It did everything and carried a lot of baggage with it. The new Kestrel web server was redesigned from the ground up to take advantage of asynchronous programming models, be much more lightweight, and fast!
Asynchronous via async/await:
.NET has excellent support for utilizing asynchronous programming patterns. Async is now implemented in all common .NET Framework classes and most third-party libraries. Most modern applications spend most of their time and CPU cycles waiting for database queries, web service calls, and other I/O operations to complete.
One of the reasons .NET Core is faster is its extensive use of asynchronous patterns within the new MVC and Kestrel frameworks.
Unified MVC & Web API frameworks:
Before .NET Core, developers were most commonly using the MVC and Web API frameworks. MVC was tailored to creating web applications that served up HTML. Web API was designed to create RESTful services using JSON or XML.
With .NET Core, MVC and Web API have been merged together. There was always a lot of overlap with the two frameworks. MVC could always return JSON data instead of HTML. Combining them was a good move and simplifies development.
With ASP.NET Core we also have the new Razor Pages. They extend the MVC framework to allow encapsulating the controller and model aspects of a page together with two-way binding. They are sort of a replacement for WebForms while using the familiar Razor syntax.
Multiple environments and development mode:
One of my favorite features is the new environment feature. It allows you to easily differentiate parts of your code for their behavior in development, staging, production, etc. There was no standard way to do this before ASP.NET Core.
For example, it is used within your Startup.cs file to help configure your application. In this case, whether or not we want to show a more detailed exception page for development only.
For example
Environments are perfect for using different CSS or Javascript files. Use your CDN in production, but local files during development. This is a snippet out of my Razor layout view.
For example
<environment names="Development"> <script src="~/lib/jquery/dist/jquery.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script> <script src="~/js/site.js" asp-append-version="true"></script> </environment> <environment names="Staging,Production"> <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js" asp-fallback-src="~/lib/jquery/dist/jquery.min.js" asp-fallback-test="window.jQuery" crossorigin="anonymous" integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk"> </script> <script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js" asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js" asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal" crossorigin="anonymous" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"> </script> <script src="~/js/site.min.js" asp-append-version="true"></script> </environment>
“Self hosted” Web Applications:
Sometimes you need to make a web application that will be deployed on to a desktop and not a server running IIS. Our free ASP.NET profiler, Prefix, is a perfect example of this. Its front end is all HTML that is loaded from an ASP.NET application running as a Windows Service.You can create a self-hosted ASP.NET web application several different ways. In .NET 4.5 you could accomplish it by using Owin, Nancy, or WCF. For Prefix, we use ASP.NET Web API with Owin.
With .NET Core, you can also use the standard Kestrel web server. One of the great advantages of .NET Core is that your web application is essentially a console application. IIS just sits in front of it as a reverse proxy. This means that you can also deploy your app only with kestrel for non-server based use cases, like Prefix.
The .net core platform
Main parts of the .Net Core Platform −
- The .Net Runtime − It provides a type system, assembly loading, a garbage collector, native interop and other basic services.
- Fundamental Libraries − A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.
- SDK & Compiler − A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.
- ‘dotnet’ app host − It is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.
.Net core versioning history
LTS - Long-term support (LTS) release have an extended support period
Maintenance - maintenance is the support stage following the release of a new current or LTS. Release in maintenance will receive security updates until reaching end-of-life
End of life - This release has reached end of life, meaning it no longer supports.