Why ASP.NET Core - Understanding what's new
ASP.Net Core, the redesigned version of ASP.Net, is leaner, has a modular framework and is suitable for cross-platform, high-performance, cloud-based modern applications. Although it’s a new framework, it has matured enough and has many advantages that make it suitable for use as the foundation of well-structured and extendable web applications such as nopCommerce.
Let’s look at some of the highlights of Asp.Net Core that have made it so popular in such little time:
Unlike .Net and ASP.Net framework, .Net Core and ASP.Net Core framework can run on multiple platforms like Windows, Linux, Mac, etc. This gives flexibility to .Net core developers to build applications for other platforms, too – and not just Windows.
The complete source code of .Net Core and ASP.Net core is available under opensource license. This gives developers the flexibility to customize or extend the functionality by modifying the source code as per their needs.
.Net Core and ASP.Net Core use a modular architecture in which individual modules are created as NuGet Packages. Since it is a modular architecture, developers need to install only those modules which are required for the application. This feature will reduce the overall application size and improve overall performance.
Supports Hosting Independence
When it comes to ASP.NET Core application development, the applications can run on web servers other than IIS (Internet Information Services) – unlike ASP.NET application development. This is because, as ASP.NET Core supports cross-platform, it cannot keep the application dependent only on IIS.
Earlier, IIS used to be the default server for ASP.NET applications. Moreover, ASP.NET Core gives a specification of OWIN (Open Web Interface for .NET) application.
Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files. For example, the built-in ‘ImageTagHelper’ can append a version number to the image name. Whenever the image changes, the server generates a new unique version for the image, so clients are guaranteed to get the current image (instead of a cached image).
This is a newly added feature in ASP.NET Core MVC, wherein View Components are similar to partial views, but they are much more powerful. View Components don’t use model binding and only depend on the data you provide when calling into it. A view component does the following:
• Renders a chunk rather than a whole response
• Includes the same separation-of-concerns and testability benefits found between a controller and view
• Can have parameters and business logic
• Is typically invoked from a layout page
Built-in Dependency Injection
ASP.NET Core is designed from the ground-up to support and leverage dependency injection. ASP.NET Core applications can leverage built-in framework services by having them injected into methods in the Startup class, and application services can be configured for injection as well. The default services container provided by ASP.NET Core provides a minimal feature set and is not intended to replace other containers.
With all these advantages, many existing applications built on ASP.Net are migrating to ASP.Net Core and one such application is our favourite eCommerce platform nopCommerce. For more details on why nopCommerce decided to move to ASP.Net Core, please refer to this nopCommerce blog.
Manjunath Govindappa | ASP.NET Technical Lead
Shwetha Bhat | Blogger