.NET 5 vs ASP.NET for MVC web applications Part 1

The newest version of .NET is out and for web developers such as myself, there should be new changes in comparison to the last previous versions. I was asked by my supervisor, to delve into the differences between the old ASP.NET MVC, which I am currently using in a web application that was developed before ASP.NET Core existed and the knowledge about the new framework changes can be helpful in a future upgrade to the newest .NET framework (V5).

The first point of knowledge I gained is that .NET 5 will be based on the ASP.NET Core framework, when it comes to web applications using the MVC architecture. So I will be mainly discussing the changes made from ASP.NET to ASP.NET Core, as those are relevant to my case.

Improvements

I think it is best to first explain what has become better with the introduction of ASP.NET Core in comparison to ASP.NET

  • Apps can be developed to run on Windows, Mac and Linux
  • There are new tools that make web development easier
  • Similar architecture for MVC and WEB API applications
  • Cloud-ready environment-based configuration
  • Built-in methods for dependency injection

Biggest change (for me at least)

Different project structure

ASP.NET MVC
ASP.NET Core MVC

As you can see there are a lot more folders and files in the ASP.NET MVC version (1). You have a folder for web content (such as HTML and CSS files) called “Content” and in the ASP.NET Core version (2) there is a folder with a helpful web icon, that stores these files.

There is also a lot less configuration files. Previously you had to set all your web configurations in the “web.config” file (1), but now most of these configurations are set in the project file and you can write your settings (such as connection strings, URLs etc…) in the “appsettings.json” file (2). There is also the fact, that you can save this information in a JSON file instead of an XML file.

Now you also only have two classes that handle the main start-up logic, the “Program.cs”, where the main method is, and the “Startup.cs” file that handles the implements the environment specific configurations (2). The ASP.NET Version (1) is in my opinion a little more cryptic when it comes to configuration classes as these belong to files named “Global.asax” and it is a little confusing to understand what is in that class.

I’ll show you how simple it is in ASP.NET Core

Configure Services method (Startup class)
Configure method (Startup class)
Methods in Program class

This is the main aspect to take care if you decide to upgrade from ASP.NET to ASP.NET Core. More Changes will be discussed in a future blogpost.