ASP.NET Core, an upgraded version of the ASP.NET web framework, is an open source and multi-platform framework primarily intended to be used on the .NET Core platform. You can develop cloud-oriented applications, including web and IoT apps, as well as mobile back-end apps with multi-OS support for Linux, MacOS and Windows.
The .NET Core platform and ASP.NET were built with a modular architecture. This results in minimal overhead. Additional functionality can be stacked on as NuGet packages, which reduces the application size and memory consumption while providing high performance and easier maintenance.
ASP.NET and .NET Core similarities and differences
ASP.NET Core shares some elements from its counterpart ASP.NET, such as the just-in-time compiler, the garbage collector and types such as List and String. In either runtime, developers can create libraries and applications in VB.NET, F# and C#.
Developers can use the .NET framework to build Windows applications for desktop or server. However, through .NET Core, they can develop cross-platform server applications but not UI-based desktop applications. Each option serves a different purpose.
A distinct change in the architectural design was the unification of the ASP.NET web API and ASP.NET MVC into ASP.NET Core. This means developers no longer must write different versions of code for .NET Web API and .NET MVC, as both libraries have been merged into a single, consistent ASP.NET MVC within .NET Core. The upgraded framework supports Razor Pages, API endpoints and view-based scenarios.
Now, let's look at the parts that make up .NET Core.
Key components of .NET Core
The key components of .NET core are EF Core, MVC Core and Identity Core.
An updated version of the entity framework, EF Core is an object/relational mapping framework that is lightweight, open source, expandable and provides multi-platform support. Although primarily meant to be used with ASP.NET Core applications, developers can also use it with standard .NET 4.5+ applications.
With EF Core, developers need to choose between two development approaches -- code-first or database-first. While code-first is the default mode for EF Core, there is also support for the database-first approach.
Like EF Core, MVC Core is an open source, lightweight and thoroughly testable framework. In the MVC, or model view controller, architecture, there are three primary components: models, views and controllers. All user requests are handled through a controller, which will call on the model to retrieve data or execute requests. The resulting model is forwarded to a view by the controller and eventually presented to the user.
With a pattern-based method, you can build dynamic websites through .NET Core MVC. It also supports test-driven development and gives you complete control over markup while being able to use the latest web standards.
ASP.NET Core Identity is an API that manages authentication activities for .NET core web apps through its UI login feature. It handles users, passwords, roles, claims, profile data and tokens. The identity configuration is done using persistent storage such as a SQL server or Azure Table Storage, which stores all data.
.NET Core for microservices applications
One of the reasons ASP.NET Core is popular among developers is its compatibility with microservices. Although each service in a microservices application works independently, these services are also interdependent for various other functionalities. ASP.NET Core adopted the microservices architecture early.
Following are particular features that make .NET Core a good choice for microservices applications.
Multi-platform support. .NET Core works on different OSes and is compatible with multiple platform technologies. This allows developers to select any IDE of their choice to create microservices applications.
Container optimized. Most .NET Core applications can be packaged in Docker containers since the original version of .NET supported containerization technology. Along with Docker, .NET Core also supports Kubernetes for orchestration. This is especially relevant to organizations that are modernizing their technology stack to be in line with containers and Kubernetes.
Cloud support. .NET Core can support your cloud computing requirements thanks to its integrations with cloud platforms, particularly Azure. Azure cloud is usually recommended for .NET Core since both are built by Microsoft and are designed to work well with each other.
Challenges with .NET Core
If you are a beginner developer or transitioning from Java to .NET Core, you'll find some nuances to keep in mind. Key differences between the two frameworks include the following:
Needless logging. .NET Core applications tend to log all events. While this is a helpful feature, logging all events, activities and errors can strain the system, causing slower loading times.
Server overload. Server overload occurs when situations are inadequately planned and accounted for. For example, when your user base grows suddenly, it is wise to implement a load balancer in the Internet Information Services suite. Apart from this, resource exhaustion, an expired Secure Sockets Layer certificate, caching or an application pool could also lead to an overload.
Database trouble. A database problem is often the reason behind a slow webpage. It may be due to database configuration, but there could also be other factors, including complex operations on a large database or database server resource exhaustion.
Best practices when using .NET Core framework
Here are best practices that can make .NET Core more efficient:
Use aggressive caching. Application performance can be improved through aggressive response caching, as the requests made to your web server are drastically reduced.
Leverage hot code paths. Hot code paths are frequently called where most of code execution takes place. Becoming familiar with these paths will immensely reduce your debugging time and efforts while optimizing your code.
Return more data across multiple mini pages. You could very likely face performance issues if your webpage returns huge chunks of data at a time. Such designs could lead to OutOfMemoryException thread pool starvation and constant garbage collection. The alternative is to split data into chunks across many mini pages.
In scenarios where ASP.NET Core fails to meet your requirements or you just want to explore alternatives, other approaches to consider include the following:
- Spring Boot.
- Android SDK.
- Ruby on Rails.
- Laravel 5.
As a longstanding framework, .NET Core has served large organizations for years. Its active development means that it is not likely to see a decline anytime soon. If you're looking for a framework that has a large community of developers and supports modern architecture designs such as microservices and containerization, .NET Core deserves consideration.