Good afternoon, in this article we will look at the basic concept of migrating from ASP.NET to ASP.NET Core. Let’s consider the main possibilities and expediency of this transition. Let’s talk about the benefits, of which there are plenty.
The first and probably one of the most important advantages is cross-platform: all the most famous operating systems are supported, both in the direction of Windows and Unix.
The second and no less important factor is modularity, the system is completely delivered in the form of Nuget packages, which in turn allows you to optimize the application, while simultaneously accelerating both the launch and updating of individual parts, essentially similar to the designer. Additionally, this allows you to integrate additional functionality in less time.
Now let’s say a few words about performance, with the release of each new version of ASP.NET Core, performance grows and noticeably. For example, ASP.NET Core processes 2300% more requests per second than ASP.NET. These huge differences in query speed are brought about by high performance modular conveyor – Middleware. In this implementation, each part of the middleware processes the HTTP request and then decides whether to return the result to the source or pass it to the next part of the middleware.
Based on the above qualities, this transition is appropriate, especially when the load increases and the project is scalable.
Differences in projects
Structure file
The main project structure file is a file with *. csproj. And compared to ASP. Net in ASP. Net Core has been modified and optimized. Let’s look at the main differences. The first thing that catches your eye is the absence of identifiers for other projects, which improves the readability of the code, the file itself is well-edited inside the Visual Studio environment. And also a good difference is the absence of an explicit specification of files, which in turn reduces the risk of conflicts when combining XML.
Point of entry
Previously in ASP. NET, the entry point for an application was the Global.asax file. It performed the tasks of configuring routes and registering filters. One approach is to link the application and the backend that hosts the application, which is not good.
To reduce this relationship, OWIN was introduced. This tool provides a more correct way to use multiple Frameworks, and also allows you to add only modules that are currently needed to the container request. The environment itself uses Startup in terms of service configuration. The startup, in turn, registers middleware services along with the application. The intermediate service component has the ability to add one or more handlers to the processing pipeline. At the same time, the handler, having finished its work, calls the next handler.
What ASP.NET Core downloads, the entry point in the application is the Startup class and this removes the dependency on Global.asax. However, keep in mind that Startup must include the Configure method with a description of the services that will be used in the application.
Storing settings
In Asp. Net, we use Web.config to store settings. by writing the settings to the < appSettings > section as key-value pairs.
Example:
< appSettings > <add key="Login" value=" LoginValue " /> <add key="Password" value=" PasswordValue " /> </ appSettings >
In this context, we can access variables through the ConfigurationManager of the System.Configuration namespace.
What ASP.NET Core is downloading is that we are not tied to either a section or a file. We can store values in any file and load them using services on initial load. However, we have a default file in the project directory called appsettings.json.
Static files
In terms of working with files, you can also see differences in terms of optimization. Previously, in ASP.NET, such files were stored in various directories and on them we got ref.
However, in ASP.NET Core, such files are already stored in the “wwwroot” root directory, and this can already be optionally changed by the settings. You can call work with files at startup by writing app.UseStaticFiles (); in the Configure method.
Conclusions
In this article, we looked at the main features of ASP. NET and ASP. Net Core for migration. ASP.Net Core technology is actively developed and has a more optimized structure for work, and given the increase in processing speed, this makes it very effective in large projects.