ASP.NET Core is a modern framework developed by Microsoft for building scalable web applications, APIs, and cloud services.
Built on the .NET platform, ASP.NET Core is Open Source, cross-platform, and highly flexible, allowing you to develop and deploy applications on Windows, Linux, and macOS.
It is designed for modern development, with support for microservices architectures, efficient APIs, Single Page Applications (SPA), and real-time applications with SignalR.
ASP.NET Core is compatible with modern technologies, allowing for flexible deployment in Docker containers, local servers, or in the cloud with Azure.
In addition to having highly optimized performance, which allows projects to run very, very fast ^(really, it’s one of the fastest options available).
Main Features
- Open source: Developed by Microsoft and the community on GitHub.
- High performance: Optimized for fast and efficient execution.
- Flexible deployment: Compatible with Docker containers, cloud services like Azure, or local servers.
- Support for modern development: Includes tools for microservices-based development, APIs, SPA (Single Page Applications), and real-time applications with SignalR.
ASP.NET Core vs ASP.NET Framework
ASP.NET Core is the evolution of ASP.NET Framework, redesigned from the ground up to be lighter, modular, and more efficient.
If you knew its predecessor, or the name sounds familiar, you must not confuse the two. They are completely different technologies.
It is the new version of ASP.NET, a complete rewrite of ASP.NET Framework, released in 2016. It was designed from scratch to be modular, lightweight, and cross-platform.
Unlike its predecessor, ASP.NET Core does not depend on Windows or IIS, allowing applications to run on different operating systems, such as Linux and macOS.
It is the old version of ASP. It was a web development platform launched by Microsoft in 2002 as part of the first version of the .NET Framework.
It was designed to enable developers to create dynamic web applications, web services, and enterprise applications using languages like C# and VB.NET.
For more than a decade, ASP.NET Framework was the primary option for web development in the .NET ecosystem.
Although they share a similar name, they have different approaches and features, (due to Microsoft’s annoying habit of complicating things with names).
ASP.NET Core Architecture
The architecture of ASP.NET Core is designed to be lightweight and modular. It is based on a system of middleware that processes HTTP requests in a configurable pipeline.
That is, it is based on a series of “modules” or middleware. Each specific task (such as authentication, routing, or error handling)
As mentioned, the goal is to give the architecture of ASP.NET Core a modular and decoupled design, making it versatile and adaptable. Some of its main components include:
Middleware in ASP.NET Core is a chain of components that process incoming and outgoing HTTP requests. The middleware architecture is based on a request pipeline, where each component has the ability to:
- Process the request.
- Pass it to the next middleware in the chain.
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
ASP.NET Core follows the Model-View-Controller (MVC) pattern for web applications and API Controller for RESTful services.
The route configuration defines how HTTP requests are mapped to controllers and actions.
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
[HttpGet]
public IActionResult GetAll()
{
return Ok(new List<string> { "Product1", "Product2" });
}
}
ASP.NET Core includes a built-in dependency injection container that facilitates the separation of responsibilities and promotes cleaner design.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IMyService, MyService>();
}
}
Configuration in ASP.NET Core is based on files like appsettings.json
, environment variables, and other configuration providers.
{
"ConnectionStrings": {
"DefaultConnection": "Server=myServer;Database=myDB;User Id=myUser;Password=myPass;"
}
}
This is just the beginning. As we progress through the course, we will gradually cover all these concepts and technologies to build real applications and projects 🌐💻.